@import url("open-iconic/font/css/open-iconic-bootstrap.min.css");

/* Brand colors */
:root {
    --brand-green: #3e603b;
    --brand-green-light: #5c8359;
    --brand-green-dark: #2d4629;
}

html,
body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a,
.btn-link {
    color: var(--brand-green);
}

.btn-primary {
    color: #fff;
    background-color: var(--brand-green);
    border-color: var(--brand-green-dark);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--brand-green-dark);
    border-color: var(--brand-green-dark);
}

.btn-success {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
}

.btn-success:hover,
.btn-success:focus,
.btn-success:active {
    background-color: var(--brand-green-dark);
    border-color: var(--brand-green-dark);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow:
        0 0 0 0.1rem white,
        0 0 0 0.25rem var(--brand-green-light);
}

.content {
    padding-top: 1.1rem;
    max-width: 100%;
    overflow-x: hidden;
}

.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--brand-green);
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background:
        url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2x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NjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=)
            no-repeat 1rem/1.8rem,
        #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Detailed Error Toast Styles */
.detailed-error-toast {
    min-width: 400px;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.detailed-error-toast .toast-body {
    max-height: 400px;
    overflow-y: auto;
}

.detailed-error-toast pre {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    color: #495057;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.75rem;
    line-height: 1.2;
    margin: 0;
    padding: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.detailed-error-toast .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.error-details-section {
    border-left: 3px solid #dc3545;
    padding-left: 0.75rem;
    margin-left: 0.25rem;
}

/* Layout styles */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

.sidebar {
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
        flex-shrink: 0;
    }

    .content {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        max-width: 100%;
    }
}

/* Global print styles */
@media print {
    /* Hide elements marked as no-print */
    .no-print,
    .no-print * {
        display: none !important;
    }

    /* Adjust page layout for print */
    .page {
        flex-direction: column !important;
    }

    main {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .content {
        padding: 0 !important;
        max-width: none !important;
        margin: 0 !important;
    }

    /* Remove any left margins that would be caused by sidebar */
    body,
    html {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Login page specific styles */
.login-main {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--brand-green);
    padding: 1rem;
}

.login-main .container {
    max-width: 500px;
    width: 100%;
}

.login-logo {
    max-width: 300px;
    height: auto;
}

/* Login page card styling */
.login-main .card {
    border-radius: 15px;
    border: none;
}

.login-main .card-body {
    background: white;
}

.login-main h2 {
    color: var(--brand-green);
    font-weight: 600;
}

/* User dropdown fixes */
.top-row .dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.125);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    min-width: 150px;
}

.top-row .dropdown-toggle {
    border: none !important;
    background: transparent !important;
    color: white !important;
    padding: 0.5rem !important;
}

.top-row .dropdown-toggle:hover,
.top-row .dropdown-toggle:focus {
    color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: none !important;
}

.top-row .dropdown-toggle::after {
    margin-left: 0.5rem;
}

/* Invoice summary dashboard */
.summary-dashboard {
    margin-bottom: 2rem;
}

.summary-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.summary-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    flex: 1;
    min-width: 180px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.summary-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.summary-card h6 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    color: #495057;
}

.summary-card.total .value {
    color: var(--brand-green);
}

.summary-card.revenue .value {
    color: #28a745;
}

.summary-card.paid .value {
    color: #17a2b8;
}

.summary-card.unpaid .value {
    color: #ffc107;
}

.summary-card.overdue .value {
    color: #dc3545;
}

/* Navigation logout styling */
.nav-scrollable .nav-link.border-0 {
    color: #d1ecf1 !important;
    background: transparent !important;
    padding: 0.5rem 1rem;
    border-radius: 0;
}

.nav-scrollable .nav-link.border-0:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

/* Collapsible Navigation */
@media (min-width: 768px) {
    .sidebar {
        width: 250px;
        transition: width 0.3s ease;
        /* Sticky positioning (inherited from 641px breakpoint) keeps sidebar in document flow.
           No position: fixed or z-index needed — avoids stacking context overlap with main content. */
        flex-shrink: 0;
    }

    .sidebar.desktop-collapsed {
        width: 60px;
        overflow: hidden;
    }

    .sidebar.desktop-collapsed .nav-text {
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .sidebar.desktop-collapsed .navbar-brand {
        opacity: 0;
    }

    .sidebar:not(.desktop-collapsed) .nav-text {
        opacity: 1;
        transition: opacity 0.3s ease 0.1s;
    }

    .sidebar .nav-link {
        white-space: nowrap;
        overflow: hidden;
    }

    /* No margin-left needed — sticky sidebar stays in flex flow,
       and main with flex: 1 automatically fills remaining space. */
}

@media (max-width: 767px) {
    .sidebar {
        position: relative;
        width: 100%;
    }

    .page main {
        margin-left: 0;
    }

    /* On mobile, make the navigation scrollable and limit height */
    .sidebar .nav-scrollable {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* On landscape mobile (small height), make menu more compact */
    @media (max-height: 500px) {
        .sidebar {
            position: fixed;
            z-index: 1050;
            width: 100%;
            max-height: 100vh;
            overflow-y: auto;
            background-color: rgba(0, 0, 0, 0.95);
        }

        .sidebar .nav-scrollable {
            max-height: calc(100vh - 60px);
        }

        /* Make nav items more compact in landscape */
        .sidebar .nav-item {
            padding: 0.25rem 0.75rem !important;
        }

        .sidebar .nav-link {
            padding: 0.4rem 0.5rem !important;
            font-size: 0.9rem;
        }

        /* Ensure the toggle button is always visible and clickable */
        .sidebar .navbar-toggler {
            position: sticky;
            top: 0;
            z-index: 1051;
        }
    }
}

/* Detailed Excel View Styling */
.detailed-excel-table {
    font-size: 0.9rem;
    border: 2px solid #dee2e6;
}

.detailed-excel-table th {
    background-color: #343a40 !important;
    color: white;
    border: 1px solid #6c757d;
    padding: 0.5rem 0.25rem;
    vertical-align: middle;
    text-align: center;
}

.detailed-excel-table td {
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.25rem;
    vertical-align: middle;
}

.detailed-excel-table .emoji-cell {
    font-size: 1.2rem;
    text-align: center;
    padding: 0.25rem;
}

/* Clickable slot styles */
.clickable-slot {
    border: none !important;
    background: none !important;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.clickable-slot:hover {
    transform: scale(1.2);
    background-color: rgba(40, 167, 69, 0.1) !important;
    border-radius: 3px;
}

.clickable-slot:active {
    transform: scale(1.1);
}

.slot-emoji {
    font-size: 1rem;
    display: inline-block;
}

.non-clickable {
    opacity: 0.7;
}

.non-clickable:hover {
    opacity: 1;
}

.week-header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    min-width: 40px !important;
    max-width: 40px !important;
}

@media (max-width: 768px) {
    .detailed-excel-table {
        font-size: 0.8rem;
    }

    .detailed-excel-table th,
    .detailed-excel-table td {
        padding: 0.25rem 0.125rem;
    }
}

/* Subscription Page - Detailed Excel-like table styling */
.detailed-excel-table {
    font-size: 0.875rem;
    border: 2px solid #dee2e6;
}

.detailed-excel-table th {
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding: 8px 4px;
    vertical-align: middle;
}

.detailed-excel-table td {
    border: 1px solid #dee2e6;
    padding: 6px 4px;
    vertical-align: middle;
}

.detailed-excel-table .week-header {
    writing-mode: horizontal-tb;
    text-align: center;
    padding: 4px 2px;
    min-width: 50px;
}

.detailed-excel-table .emoji-cell {
    text-align: center;
    padding: 6px 2px;
    font-size: 1rem;
}

.detailed-excel-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* Responsive design for detailed view */
@media (max-width: 1200px) {
    .detailed-excel-table {
        font-size: 0.8rem;
    }

    .detailed-excel-table .week-header {
        min-width: 35px;
        font-size: 0.7rem;
    }

    .detailed-excel-table .emoji-cell {
        font-size: 0.9rem;
    }
}

/* Responsive adjustments for subscription page */
@media (max-width: 768px) {
    .subscription-products {
        min-width: 150px;
    }

    .product-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .quantity-badge {
        align-self: flex-start;
    }
}

/* Made with love footer credit in sidebar */
.made-with-love {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    padding: 0.5rem;
    line-height: 1.4;
}

.made-with-love span {
    display: block;
}

.made-with-love a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    display: block;
    margin-top: 0.25rem;
}

.made-with-love a:hover {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: underline;
}

/* Hide changelog link text when sidebar is collapsed */
.sidebar.desktop-collapsed .made-with-love {
    display: none;
}

/* Build version stamp — sits inside .made-with-love in sidebar */
.made-with-love .build-info {
    display: block;
    margin-top: 0.25rem;
    font-size: inherit;
    color: rgba(255, 255, 255, 0.25);
    user-select: all;
}

/* =========================================================
   LEAF Design System — shared classes
   ========================================================= */

/* --- Cards ------------------------------------------------ */
.leaf-card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.leaf-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.clickable-card {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background-color: rgba(0, 123, 255, 0.02);
}

/* --- Table enhancements ----------------------------------- */
.leaf-card .table {
    margin-bottom: 0;
}

.leaf-card .table thead th {
    border-top: none;
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.leaf-card .table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- Sortable column headers ------------------------------ */
.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
}

.sortable-header:hover {
    background-color: #e9ecef !important;
}

.sortable-header.active-sort {
    background-color: #e3f2fd !important;
    color: #1976d2;
}

.sortable-header i {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* --- Search container ------------------------------------- */
.search-container {
    position: relative;
}

.search-container input {
    padding-left: 2.5rem;
}

.search-container::before {
    content: "\f52a";
    font-family: "bootstrap-icons";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 10;
}

/* --- Edit-mode banner ------------------------------------- */
.edit-banner {
    border-radius: 0.375rem;
    margin-left: -1rem;
    margin-right: -1rem;
    margin-top: -1rem;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* --- Button group fix ------------------------------------- */
.btn-group .btn {
    border-radius: 0.25rem;
}

/* --- Modal z-index fix ------------------------------------ */
.modal {
    z-index: 1060;
}

.modal-backdrop {
    z-index: 1040;
}

/* --- Empty state (used by EmptyState component) ----------- */
.leaf-empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.leaf-empty-state .empty-icon {
    font-size: 2.5rem;
    color: #adb5bd;
    margin-bottom: 0.75rem;
}

.leaf-empty-state .empty-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.leaf-empty-state .empty-message {
    color: #6c757d;
    margin-bottom: 1rem;
}

/* --- Loading spinner (used by LoadingSpinner component) --- */
.leaf-loading {
    display: flex;
    justify-content: center;
    align-items: center;
}

.leaf-loading .text-center p {
    color: #6c757d;
}

/* --- Dashboard customer link hover ----------------------- */
.customer-link {
    transition: all 0.2s ease-in-out;
    border-left: 3px solid transparent;
}

.customer-link:hover {
    background-color: #f8f9fa;
    border-left-color: #0d6efd;
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.customer-link:hover .bi-arrow-right {
    color: #0d6efd !important;
    transform: translateX(3px);
}

.customer-link .bi-arrow-right {
    transition: all 0.2s ease-in-out;
}
