/* Premium Design Tokens - SaaS Edition */
:root {
    --sauber-primary: #58319b;
    --sauber-primary-hover: #46267c;
    --sauber-primary-soft: #f4efff;
    --sauber-bg: #f8fafc;
    --sauber-card-bg: #ffffff;
    --sauber-text-main: #1e293b;
    --sauber-text-secondary: #64748b;
    --sauber-text-muted: #94a3b8;
    --sauber-border: #e2e8f0;
    --sauber-border-light: #f1f5f9;
    --sauber-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --sauber-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --sauber-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* Base Styles */
.sauber-dashboard-wrapper {
    max-width: 1300px;
    margin: 32px auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--sauber-text-main);
    padding: 0 24px;
}

/* Dashboard UI Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}

.dashboard-header h2 {
    margin: 0;
    color: var(--sauber-text-main);
    font-weight: 800;
    font-size: 26px;
    letter-spacing: -0.025em;
}

/* Buttons */
.sauber-btn-primary {
    background: var(--sauber-primary);
    color: #fff;
    border: 1px solid var(--sauber-primary);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--sauber-shadow-sm);
}

.sauber-btn-primary:hover {
    background: var(--sauber-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--sauber-shadow);
}

.sauber-btn-outline {
    background: #fff;
    border: 1px solid var(--sauber-border);
    color: var(--sauber-text-main);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--sauber-shadow-sm);
}

.sauber-btn-outline:hover {
    background: var(--sauber-border-light);
    border-color: var(--sauber-text-muted);
}

/* Stats Cards */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--sauber-card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--sauber-shadow-sm);
    border: 1px solid var(--sauber-border);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.stat-card:not(.no-filter):hover {
    transform: translateY(-2px);
    box-shadow: var(--sauber-shadow);
    border-color: var(--sauber-primary);
}

.stat-card.active {
    border-color: var(--sauber-primary);
    background: var(--sauber-primary-soft);
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
}

.stat-card.no-filter {
    cursor: default;
}

.stat-card h4 {
    margin: 0 0 10px 0;
    color: var(--sauber-text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--sauber-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Modern Compact Table */
.dashboard-table-container {
    background: var(--sauber-card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--sauber-shadow);
    border: 1px solid var(--sauber-border);
    overflow: hidden;
}

.table-actions {
    padding: 24px;
    background: #f8fafc;
    border: 1px solid var(--sauber-border);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: var(--sauber-shadow-sm);
    flex-wrap: wrap;
}

.table-actions > div:first-child {
    order: 1;
    flex: 1 1 250px !important;
    max-width: 400px !important;
}

#sauber-refresh-bookings {
    order: 2;
}

.sauber-filter-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex: 1 1 100%;
    flex-wrap: wrap;
    order: 3;
    margin-top: 8px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-item label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--sauber-text-muted);
    letter-spacing: 0.08em;
    margin-left: 2px;
    line-height: 1;
}

.sauber-datepicker {
    padding: 10px 14px;
    border: 1px solid var(--sauber-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    width: 150px;
    min-width: 140px;
    height: 42px;
    background: #fff;
    transition: all 0.2s ease;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sauber-datepicker:focus {
    border-color: var(--sauber-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
}

.sauber-filter-group .sauber-btn-primary,
.sauber-filter-group .sauber-btn-outline {
    height: 42px;
    padding: 0 20px;
    white-space: nowrap;
}

.report-stats-stripe {
    background: var(--sauber-primary-soft);
    padding: 12px 24px;
    border-bottom: 1px solid var(--sauber-border);
    display: flex;
    gap: 32px;
    align-items: center;
}

.report-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--sauber-text-secondary);
}

.report-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--sauber-primary);
}

#sauber-dashboard-search {
    flex: 1;
    max-width: 400px;
    padding: 10px 16px;
    border: 1px solid var(--sauber-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s ease;
    background: #fff;
    height: 42px;
    box-sizing: border-box;
}

#sauber-refresh-bookings {
    height: 42px;
}

#sauber-dashboard-search:focus {
    border-color: var(--sauber-primary);
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
    outline: none;
}

.table-scroll {
    overflow-x: auto;
}

#sauber-bookings-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

#sauber-bookings-table th {
    background: var(--sauber-bg);
    color: var(--sauber-text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 20px;
    border-bottom: 1px solid var(--sauber-border);
    text-align: left;
}

#sauber-bookings-table td {
    padding: 14px 20px;
    vertical-align: middle;
    border-bottom: 1px solid var(--sauber-border-light);
    color: var(--sauber-text-main);
    font-size: 14px;
}

#sauber-bookings-table tr:hover td {
    background: #fbfcfe;
}

#sauber-bookings-table tr:last-child td {
    border-bottom: none;
}

/* Modern SaaS Badges */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    letter-spacing: -0.01em;
}

.badge-pending { background: #fff7ed; color: #c2410c; }
.badge-confirmed { background: #f0fdf4; color: #15803d; }
.badge-completed { background: #f0f9ff; color: #0369a1; }
.badge-cancelled { background: #fef2f2; color: #b91c1c; }
.badge-paid { background: #f0fdf4; color: #166534; }
.badge-unpaid { background: #fffbeb; color: #92400e; }

/* High-Visibility SaaS Action Buttons */
.sauber-dashboard-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding: 0;
}

.sauber-dashboard-action-btn svg {
    display: block;
    fill: none;
    pointer-events: none;
}

.btn-edit-sauber {
    background: #e0e7ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

.btn-edit-sauber:hover {
    background: #c7d2fe;
    color: #312e81;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(55, 48, 163, 0.2);
}

.btn-delete-sauber {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.btn-delete-sauber:hover {
    background: #fecaca;
    color: #7f1d1d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153, 27, 27, 0.2);
}

.btn-invoice-sauber {
    background: #f5f3ff;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
}

.btn-invoice-sauber:hover {
    background: #5b21b6;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(91, 33, 182, 0.3);
}

.btn-invoice-sauber svg {
    stroke: currentColor;
}

/* Premium Modal V2 */
.sauber-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.sauber-modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #fff;
    box-shadow: var(--sauber-shadow-lg);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 500px;
    max-width: 95%;
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

/* Beautiful Slim scrollbar for modal content */
.modal-content::-webkit-scrollbar {
    width: 6px;
}
.modal-content::-webkit-scrollbar-track {
    background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Body scroll lock when modal is open */
html.sauber-modal-open,
body.sauber-modal-open {
    overflow: hidden !important;
}


.sauber-modal.active .modal-content {
    animation: slideUp 0.3s ease;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--sauber-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.close-modal:hover {
    background: var(--sauber-bg);
    color: var(--sauber-text-main);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Edit Form Styles */
.sauber-modal h3 {
    margin: 0 0 24px 0;
    font-size: 20px;
    font-weight: 700;
}

.sauber-modal .form-group {
    margin-bottom: 16px;
    text-align: left;
}

.sauber-modal label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--sauber-text-secondary);
}

.sauber-modal input, .sauber-modal select {
    border: 1px solid var(--sauber-border);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    width: 100%;
}

/* Custom alignment for amount column */
#sauber-bookings-table th:nth-child(6),
#sauber-bookings-table td:nth-child(6) {
    text-align: right;
}

/* Scrollbar styling */
.table-scroll::-webkit-scrollbar {
    height: 8px;
}
.table-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Login Page Premium Styles */
.sauber-login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 20px;
    background: radial-gradient(circle at top right, #f4efff 0%, #f8fafc 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sauber-login-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    padding: 48px;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(88, 49, 155, 0.05), 0 10px 10px -5px rgba(88, 49, 155, 0.02);
    border: 1px solid rgba(88, 49, 155, 0.08);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sauber-login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--sauber-primary), #7b4dc4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--sauber-primary-soft);
    color: var(--sauber-primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 16px rgba(88, 49, 155, 0.1);
}

.login-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--sauber-text-main);
    margin: 0 0 8px 0;
    letter-spacing: -0.025em;
}

.login-header h2 span {
    color: var(--sauber-primary);
}

.login-header p {
    color: var(--sauber-text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.sauber-login-card .form-group {
    margin-bottom: 24px;
}

.sauber-login-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--sauber-text-main);
    margin-bottom: 8px;
    margin-left: 2px;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sauber-text-muted);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1.5px solid var(--sauber-border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--sauber-text-main);
    transition: all 0.2s ease;
    background: #fff;
    box-sizing: border-box;
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--sauber-primary);
    box-shadow: 0 0 0 4px var(--sauber-primary-soft);
}

.input-with-icon input:focus + .input-icon,
.input-with-icon input:not(:placeholder-shown) + .input-icon {
    color: var(--sauber-primary);
}

.sauber-login-btn {
    width: 100%;
    padding: 14px;
    background: var(--sauber-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 15px -3px rgba(88, 49, 155, 0.2);
}

.sauber-login-btn:hover {
    background: var(--sauber-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(88, 49, 155, 0.25);
}

.sauber-login-btn:active {
    transform: translateY(0);
}

.sauber-login-btn svg {
    transition: transform 0.2s ease;
}

.sauber-login-btn:hover svg {
    transform: translateX(4px);
}

.login-footer {
    margin-top: 32px;
    font-size: 13px;
    color: var(--sauber-text-muted);
    font-weight: 500;
}

/* Feedback messages styling */
.feedback-msg {
    margin-top: 20px;
    font-size: 14px;
    text-align: center;
    min-height: 20px;
    font-weight: 600;
    border-radius: 8px;
    padding: 0;
    transition: all 0.3s ease;
}

.feedback-msg.error {
    color: #df1b41;
}

/* Edit Invoice Modal Styles */
#sauber-edit-invoice-modal .modal-content {
    background: #fff;
    box-shadow: var(--sauber-shadow-lg);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 850px;
    max-width: 95%;
    position: relative;
}

.sauber-invoice-items-table th,
.sauber-invoice-items-table td {
    padding: 10px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--sauber-border);
}

.sauber-invoice-items-table tbody tr:hover {
    background-color: var(--sauber-bg);
}

.sauber-invoice-items-table input.item-name-input {
    width: 100%;
    border: 1px solid var(--sauber-border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: transparent;
    transition: all 0.2s ease;
}

.sauber-invoice-items-table input.item-name-input:focus {
    border-color: var(--sauber-primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
}

.sauber-invoice-items-table input.item-qty-input,
.sauber-invoice-items-table input.item-price-input {
    width: 100%;
    border: 1px solid var(--sauber-border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
    background: transparent;
    transition: all 0.2s ease;
}

.sauber-invoice-items-table input.item-price-input {
    text-align: right;
}

.sauber-invoice-items-table input.item-qty-input:focus,
.sauber-invoice-items-table input.item-price-input:focus {
    border-color: var(--sauber-primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
}

.sauber-invoice-items-table .item-total-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--sauber-text-main);
}

.sauber-invoice-items-table .delete-row-btn {
    background: none;
    border: none;
    color: var(--sauber-text-muted);
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.sauber-invoice-items-table .delete-row-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

#edit-invoice-notes:focus,
#edit-invoice-extra-charges:focus,
#edit-invoice-discount:focus {
    border-color: var(--sauber-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--sauber-primary-soft);
}

/* Base Utility for the wrapper (adjusting existing) */
#sauber-dashboard-login-container.sauber-login-wrapper {
    max-width: 100%;
    margin: 0;
    padding: 40px 20px;
}

@media (max-width: 768px) {
    .sauber-dashboard-wrapper {
        padding: 0 16px;
        margin: 20px auto;
    }

    /* Modal responsive adjustments */
    .modal-content {
        padding: 24px 20px;
        border-radius: var(--radius-md);
    }
    
    .sauber-modal .row {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .sauber-modal .form-group {
        margin-bottom: 12px;
    }


    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .dashboard-header .sauber-btn-outline {
        width: 100%;
    }

    .table-actions {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .table-actions > div:first-child {
        order: 1;
        max-width: 100% !important;
    }

    .sauber-filter-group {
        order: 2;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        margin-top: 0;
    }

    #sauber-refresh-bookings {
        order: 3;
    }

    .sauber-datepicker {
        width: 100% !important;
    }

    #sauber-dashboard-search {
        max-width: 100%;
    }

    .report-stats-stripe {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    /* Admin Table Mobile Card View */
    #sauber-bookings-table, 
    #sauber-bookings-table tbody, 
    #sauber-bookings-table tr, 
    #sauber-bookings-table td {
        display: block;
        width: 100%;
    }

    #sauber-bookings-table thead {
        display: none;
    }

    #sauber-bookings-table tr {
        margin-bottom: 16px;
        border: 1px solid var(--sauber-border);
        border-radius: var(--radius-lg);
        padding: 12px;
        background: #fff;
        box-shadow: var(--sauber-shadow-sm);
    }

    #sauber-bookings-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 0;
        border-bottom: 1px solid var(--sauber-border-light);
        min-height: 40px;
    }

    #sauber-bookings-table td:last-child {
        border-bottom: none;
        padding-top: 15px;
        justify-content: center;
    }

    #sauber-bookings-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--sauber-primary);
        font-size: 11px;
        text-transform: uppercase;
        text-align: left;
    }

    /* Hide less critical columns on mobile */
    #sauber-bookings-table td[data-label="Contact"],
    #sauber-bookings-table td[data-label="Created"] {
        display: none;
    }

    /* Login Card Mobile Fixes */
    .sauber-login-card {
        padding: 40px 24px;
        border-radius: 20px;
    }

    .login-header h2 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .dashboard-header h2 {
        font-size: 22px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }
}