/* PPH Manager - Stylesheet */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-tertiary: #243447;
    --text-primary: #ffffff;
    --text-secondary: #8899a6;
    --text-muted: #657786;
    --accent-blue: #1da1f2;
    --accent-green: #17bf63;
    --accent-red: #e0245e;
    --accent-orange: #f5a623;
    --border-color: #38444d;
    --table-header: #192734;
    --table-row-hover: #22303c;
}

/* Light theme overrides */
body.light-theme {
    --bg-primary: #f4f6f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf0f3;
    --text-primary: #14171a;
    --text-secondary: #536471;
    --text-muted: #8899a6;
    --accent-blue: #1a8cd8;
    --accent-green: #00a651;
    --accent-red: #c0183e;
    --accent-orange: #d4840e;
    --border-color: #d6dce1;
    --table-header: #e8edf1;
    --table-row-hover: #edf0f3;
}

/* Smooth transition when switching themes */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
    transition: background-color 0.25s ease, color 0.25s ease,
                border-color 0.25s ease, box-shadow 0.25s ease !important;
}

/* Theme toggle button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.theme-toggle-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.85;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Sidebar Layout */
body.has-sidebar {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    min-width: 220px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand a {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background-color: var(--bg-tertiary);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.sidebar-nav a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-user span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

body.has-sidebar .main-content {
    margin-left: 220px;
    max-width: calc(100vw - 220px);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 201;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-container.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 1.5rem;
}

.modal-content .info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-content .info-row:last-child {
    border-bottom: none;
}

.modal-content .info-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-content .info-value {
    font-weight: 500;
}

.modal-content .modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Legacy navbar (for login page) */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
}

/* Container (for login page without sidebar) */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    border-color: var(--primary);
}

.stat-card.stat-card-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-blue);
}

.stat-value.negative {
    color: var(--accent-red);
}

.stat-value.positive {
    color: var(--accent-green);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--table-header);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background-color: var(--table-row-hover);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* Balance colors */
.balance-negative {
    color: var(--accent-red);
    font-weight: 600;
}

.balance-positive {
    color: var(--accent-green);
    font-weight: 600;
}

.balance-zero {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background-color: #1991db;
}

.btn-success {
    background-color: var(--accent-green);
    color: white;
}

.btn-success:hover {
    background-color: #15a857;
}

.btn-danger {
    background-color: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    background-color: #c91e52;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-orange {
    background-color: var(--accent-orange);
    color: white;
}

.btn-orange:hover {
    background-color: #e09620;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    height: 2.75rem;
    padding: 0 1rem;
    box-sizing: border-box;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 2.75rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-checkbox input {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Alerts */
/* Legacy inline alerts (kept for any direct uses) */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.alert-success { background-color: rgba(23, 191, 99, 0.1); border: 1px solid var(--accent-green); color: var(--accent-green); }
.alert-error   { background-color: rgba(224, 36, 94, 0.1);  border: 1px solid var(--accent-red);   color: var(--accent-red);   }
.alert-warning { background-color: rgba(245, 166, 35, 0.1); border: 1px solid #f5a623;             color: #f5a623;             }
.alert-close   { background: none; border: none; color: inherit; font-size: 1.25rem; cursor: pointer; }

/* Toast notifications — fixed bottom-right, no layout shift */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    min-width: 220px;
    max-width: 380px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    pointer-events: all;
    opacity: 0;
    transform: translateY(12px);
    animation: toast-in 0.25s ease forwards;
}

.toast.toast-hide {
    animation: toast-out 0.25s ease forwards;
}

.toast-success {
    background: rgba(23, 191, 99, 0.18);
    border: 1px solid rgba(23, 191, 99, 0.5);
    color: var(--accent-green);
}

.toast-error {
    background: rgba(224, 36, 94, 0.18);
    border: 1px solid rgba(224, 36, 94, 0.5);
    color: var(--accent-red);
}

.toast-warning {
    background: rgba(245, 166, 35, 0.18);
    border: 1px solid rgba(245, 166, 35, 0.5);
    color: #f5a623;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.7;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.toast-close:hover { opacity: 1; }

@keyframes toast-in {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(12px); }
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: bold;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Dropdown/Select Styling */
.agent-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: rgba(23, 191, 99, 0.2);
    color: var(--accent-green);
}

.badge-warning {
    background-color: rgba(245, 166, 35, 0.2);
    color: var(--accent-orange);
}

.badge-danger {
    background-color: rgba(224, 36, 94, 0.2);
    color: var(--accent-red);
}

.badge-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    margin-bottom: 2rem;
}

/* Week Navigation */
.week-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.week-nav select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

.main-header {
    display: none; /* Hidden by default, shown in responsive */
}

/* Actions column */
.actions {
    text-align: right;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
        min-width: 70px;
    }

    .sidebar-brand {
        padding: 1rem;
        text-align: center;
    }

    .sidebar-brand a {
        font-size: 1rem;
    }

    .sidebar-nav a {
        padding: 1rem;
        justify-content: center;
    }

    .sidebar-nav a span,
    .sidebar-nav a:not(:has(svg))::after {
        display: none;
    }

    .sidebar-footer {
        padding: 0.75rem;
    }

    .sidebar-user {
        flex-direction: column;
        gap: 0.5rem;
    }

    .sidebar-user span {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        max-width: calc(100vw - 70px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 220px;
        min-width: 220px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 199;
        display: none;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Reset compressed sidebar styles from the tablet breakpoint */
    .sidebar-brand {
        padding: 1.5rem;
        text-align: left;
    }

    .sidebar-brand a {
        font-size: 1.25rem;
    }

    .sidebar-nav a {
        padding: 0.875rem 1.5rem;
        justify-content: flex-start;
    }

    .sidebar-footer {
        padding: 1rem 1.5rem;
    }

    .sidebar-user {
        flex-direction: row;
    }

    .sidebar-user span {
        display: block;
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 1rem;
    }

    .main-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .sidebar-toggle {
        background: none;
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        padding: 0.5rem;
        border-radius: 6px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .sidebar-toggle svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        stroke-width: 2;
        fill: none;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}


/* Balance History specific styles (matching screenshot) */
.balance-table th,
.balance-table td {
    padding: 0.875rem 1rem;
}

.balance-table .week-col {
    color: var(--accent-blue);
    font-weight: 500;
}

.balance-forward-row {
    background-color: var(--bg-tertiary);
}

.balance-forward-row td {
    font-weight: 600;
}

/* Settings sub-navigation tabs */
.settings-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.settings-tab {
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.settings-tab:hover {
    color: var(--text-primary);
}
.settings-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}
