/*
 * CyberLedger Simple Design Stylesheet
 * Clean, lightweight, professional light-themed layout
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --border-color: #d1d5db;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning: #f59e0b;
    --table-header-bg: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.5;
}

/* Authentication Layout */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.auth-logo {
    text-align: center;
    margin-bottom: 25px;
}

.auth-logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #111827;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
}

.input-control {
    width: 100%;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.95rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary {
    width: 100%;
    padding: 10px 16px;
    background-color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.auth-links {
    margin-top: 20px;
    text-align: center;
    font-size: 0.875rem;
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.alert-danger {
    background-color: var(--error-bg);
    border: 1px solid #fca5a5;
    color: var(--error-text);
}

.alert-success {
    background-color: var(--success-bg);
    border: 1px solid #a7f3d0;
    color: var(--success-text);
}

/* Header / Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #111827;
    text-decoration: none;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-secondary {
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.user-tag {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Dashboard Grid */
.main-content {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.period-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
}

.period-picker label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.period-picker input {
    border: none;
    font-weight: 600;
    outline: none;
    color: var(--text-color);
    font-family: inherit;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    color: white;
}

.btn-teal {
    background: #0f766e;
}
.btn-teal:hover {
    background: #115e59;
}

.btn-indigo {
    background: #4338ca;
}
.btn-indigo:hover {
    background: #3730a3;
}

.btn-emerald {
    background: #047857;
}
.btn-emerald:hover {
    background: #065f46;
}

/* Ledger Spreadsheet Table */
.ledger-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ledger-month-header {
    background: #f9fafb;
    text-align: center;
    padding: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    color: #111827;
}

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

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.ledger-table th {
    background-color: var(--table-header-bg);
    color: white;
	text-align:center;
    font-weight: 600;
    padding: 10px 14px;
    border-right: 1px solid #374151;
}

.ledger-table th:last-child {
    border-right: none;
}

.ledger-table td {
	text-align:center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.ledger-table td:last-child {
    border-right: none;
}

.ledger-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.cell-number {
    font-family: 'JetBrains Mono', monospace;
    text-align: right;
}

.cell-bold {
    font-weight: 600;
}

.cell-profit {
    color: #047857;
}

.cell-loss {
    color: #b91c1c;
}

/* Total row matches spreadsheet */
.ledger-table tr.total-row {
    background-color: #f3f4f6 !important;
    font-weight: 700;
    border-top: 2px solid #9ca3af;
    border-bottom: 2px solid #9ca3af;
}

.ledger-table tr.total-row td {
    font-family: 'JetBrains Mono', monospace;
}

.ledger-table tr.label-row td {
    border: none;
    padding: 3px 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

.ledger-table tr.label-row td.text-center {
    text-align: center;
}

/* Footer Summary Cards */
.ledger-footer-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 15px 20px;
    gap: 10px;
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    max-width: 360px;
}

.summary-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-right: 20px;
    flex-grow: 1;
    text-align: right;
}

.summary-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    width: 130px;
    text-align: right;
}

.ads-cost-form {
    width: auto;
}

.ads-cost-form form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ads-input-wrapper {
    position: relative;
    width: 110px;
}

.ads-currency-prefix {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.ads-input {
    width: 100%;
    padding: 6px 10px 6px 22px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    background: #ffffff;
    text-align: right;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    height: 34px;
}

.ads-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-ads-save {
    padding: 0 14px;
    height: 34px;
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ads-save:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-ads-save:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-ads-save:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

/* Spreadsheet Highlight Bar */
.net-profit-bar {
    background-color: #d1fae5;
    border: 1px solid #10b981;
    border-radius: 4px;
    padding: 6px 12px;
    width: 100%;
    max-width: 360px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.net-profit-bar .summary-label {
    color: var(--success-text);
}

.net-profit-bar .summary-value {
    color: var(--success-text);
    font-size: 1.1rem;
}

.empty-ledger-view {
    text-align: center;
    padding: 40px 10px;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex-grow: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    color: black;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
}

.row-divider {
    border-top: 1px solid var(--border-color);
    margin: 15px 0;
}

.dynamic-variation-row {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    position: relative;
}

.btn-remove-row {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.15s ease;
}

.btn-remove-row:hover {
    color: #b91c1c;
}

.btn-add-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f3f4f6;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.btn-add-more:hover {
    background: #e5e7eb;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: #f9fafb;
}

.modal-footer .btn-secondary {
    padding: 8px 16px;
}

.modal-footer .btn-primary {
    width: auto;
    padding: 8px 16px;
}

/* Tags List */
.variation-tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-height: 40px;
    align-items: center;
}

.variation-tag {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.variation-tag-remove {
    cursor: pointer;
    font-weight: bold;
}

.tag-helper-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    flex-grow: 1;
    min-width: 120px;
}

/* Media Query overrides */
@media(max-width: 768px) {
    .navbar {
        padding: 10px 15px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .nav-actions {
        width: 100%;
        justify-content: center;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        text-align: center;
    }
    .dashboard-header div {
        width: 100%;
    }
    .dashboard-header .btn-icon, 
    .dashboard-header .btn-teal {
        width: 100%;
        justify-content: center;
    }
    .action-buttons {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 8px;
    }
    .action-buttons .btn-icon {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
    }
    .form-grid-3, .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .ledger-footer-summary {
        align-items: stretch;
        padding: 15px;
    }
    .summary-row, .net-profit-bar {
        max-width: 100%;
    }
    .summary-label {
        text-align: left;
        margin-right: 10px;
    }
    .dropdown-menu {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
    @keyframes dropdownFadeIn {
        from { opacity: 0; transform: translate(-50%, -5px); }
        to { opacity: 1; transform: translate(-50%, 0); }
    }
    .btn-remove-row {
        position: relative;
        top: 0;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-bottom: 12px;
        background: #fee2e2;
        color: #b91c1c;
        border: 1px solid #fca5a5;
        padding: 8px;
        font-size: 0.85rem;
        font-weight: 600;
        text-align: center;
        border-radius: 4px;
        box-sizing: border-box;
    }
    .btn-remove-row::before {
        content: "Remove Variation ";
        margin-right: 4px;
    }
}

/* User Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-color);
    transition: background 0.15s ease, border-color 0.15s ease;
    font-weight: 500;
    font-family: inherit;
    outline: none;
}

.dropdown-trigger strong {
    font-weight: 600;
}

.dropdown-trigger:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.dropdown-caret {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 170px;
    z-index: 1000;
    overflow: hidden;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.15s ease;
    text-align: left;
}

.dropdown-menu a:hover {
    background-color: #f3f4f6;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.dropdown-menu .dropdown-item-logout {
    color: var(--error-text);
}

.dropdown-menu .dropdown-item-logout:hover {
    background-color: var(--error-bg);
}

/* Top Header Bar */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #1f2937; /* Dark Slate Gray - Same as sidebar */
    color: #ffffff;
    height: 60px;
    box-sizing: border-box;
    border-bottom: 1px solid #374151;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
}

.header-actions {
    display: flex;
    align-items: center;
}

/* Dark theme overrides for top-header dropdown trigger */
.top-header .dropdown-trigger {
    background: transparent;
    border: 1px solid #374151;
    color: #ffffff;
}

.top-header .dropdown-trigger:hover {
    background: #374151;
    border-color: #4b5563;
}

.top-header .dropdown-caret {
    color: #9ca3af;
}

/* Edit Pen trigger styles */
.value-edit-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    justify-content: flex-end;
}

.value-edit-trigger:hover {
    background-color: #f3f4f6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.edit-pen-icon {
    color: var(--text-muted);
    opacity: 0.4;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.value-edit-trigger:hover .edit-pen-icon {
    opacity: 1;
    color: var(--primary);
}

/* Layout container */
.app-container {
    display: flex;
    min-height: calc(100vh - 60px);
    width: 100%;
}

/* Sidebar styling */
.sidebar {
    width: 260px;
    background: #1f2937; /* Dark Slate Gray */
    color: #f3f4f6;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 100;
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

/* Hide sidebar logo and user block on desktop */
.sidebar .sidebar-logo,
.sidebar .sidebar-user {
    display: none;
}

.sidebar-logo {
    padding: 24px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #ffffff;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user {
    padding: 16px 24px;
    background: #111827; /* Darker background */
    border-bottom: 1px solid #374151;
    font-size: 0.85rem;
    color: #9ca3af;
}
.sidebar-user strong {
    color: #ffffff;
    display: block;
    font-size: 0.95rem;
    margin-top: 4px;
}

.sidebar-menu {
    padding: 20px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 4px solid transparent;
}

.sidebar-link:hover {
    background: #374151;
    color: #ffffff;
}

.sidebar-link.active {
    background: #374151;
    color: #ffffff;
    border-left-color: var(--primary); /* Teal accent */
    font-weight: 600;
}

.sidebar-link-logout {
    color: #fca5a5;
    border-top: 1px solid #374151;
    margin-top: auto;
    padding-top: 16px;
}

.sidebar-link-logout:hover {
    background: var(--error-bg);
    color: #ffffff;
}

/* Main Content Area */
.app-content {
    flex-grow: 1;
    background: var(--bg-color);
    padding: 40px;
    overflow-y: auto;
    max-height: 100vh;
    box-sizing: border-box;
}

/* Mobile Sidebar & Header */
.mobile-header {
    display: none;
    background: #1f2937;
    color: white;
    padding: 15px 20px;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
}

.mobile-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

/* Mobile responsive styles */
@media(max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        max-height: none;
        overflow-y: auto;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid #374151;
        border-bottom: none;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        max-height: none;
        border-bottom: none;
    }
    .sidebar-close {
        display: flex !important;
    }
    .mobile-header {
        display: flex;
    }
    .app-content {
        padding: 20px;
        max-height: none;
    }
    .top-bar {
        display: none !important;
    }
    .top-header {
        display: none !important;
    }
    .sidebar .sidebar-logo,
    .sidebar .sidebar-user {
        display: flex;
    }
    .sidebar .sidebar-user {
        display: block;
    }
}


