/**
 * Gratus Accounting - Custom Styles
 * Companion to Tailwind CSS — only non-Tailwind overrides and layout helpers
 */

:root {
    --primary-blue: #2563eb;
    --primary-blue-hover: #1d4ed8;
    --secondary-gray: #6b7280;
    --light-gray: #f9fafb;
    --border-gray: #e5e7eb;
    --text-dark: #111827;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-yellow: #f59e0b;
    --sidebar-width: 260px;
}

/* ============================================================
   Base
   ============================================================ */
body, html {
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--light-gray); }
::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary-gray); }

/* ============================================================
   Layout — Sidebar + Main content
   ============================================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--border-gray);
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.3s ease;
}

.navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border-gray);
    z-index: 100;
    display: flex;
    align-items: center;
}

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 64px;
    padding: 24px;
    min-height: calc(100vh - 64px);
    background: var(--light-gray);
}

/* ============================================================
   Sidebar Items
   ============================================================ */
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-item:hover {
    background: #dcfce7;
    color: #15803d;
    border-left-color: transparent;
}

.sidebar-item.active {
    background: #dcfce7;
    color: #15803d;
    border-left-color: #16a34a;
    font-weight: 600;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    border: 1px solid var(--border-gray);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

/* ============================================================
   Amount Indicators
   ============================================================ */
.amount-positive { color: var(--success-green); }
.amount-negative { color: var(--danger-red); }
.amount-neutral  { color: var(--secondary-gray); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #374151; }

/* ============================================================
   Buttons (supplemental — use Tailwind classes primarily)
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary  { background: var(--primary-blue); color: #fff; }
.btn-primary:hover { background: var(--primary-blue-hover); }
.btn-success  { background: var(--success-green); color: #fff; }
.btn-danger   { background: var(--danger-red); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border-gray); color: var(--text-dark); }
.btn-outline:hover { background: var(--light-gray); }
.btn-csv { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 20px; border-radius: 8px; border: 2px solid #16a34a; color: #16a34a; font-weight: 600; font-size: 0.875rem; cursor: pointer; transition: background 0.18s ease, color 0.18s ease; background: transparent; white-space: nowrap; text-decoration: none; }
.btn-csv:hover { background: #16a34a; color: #fff; }
.btn-new { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 20px; border-radius: 8px; border: 2px solid #2563eb; color: #2563eb; font-weight: 600; font-size: 0.875rem; cursor: pointer; transition: background 0.18s ease, color 0.18s ease; background: transparent; white-space: nowrap; text-decoration: none; }
.btn-new:hover { background: #2563eb; color: #fff; }

/* ============================================================
   Tables
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-gray);
}

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

.table thead th {
    background: var(--light-gray);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid var(--border-gray);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-gray);
    color: #374151;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

/* ============================================================
   Input Fields — auth pages (mirrors Gratus Investments style)
   ============================================================ */
.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    background: #f9fafb;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.input-field::placeholder {
    color: #c4c9d4;
    font-size: 13px;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

/* ============================================================
   Forms (supplemental)
   ============================================================ */
.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-dark);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-control.error { border-color: var(--danger-red); }
.form-error { font-size: 0.75rem; color: var(--danger-red); margin-top: 4px; }

/* ============================================================
   Alert Messages
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ============================================================
   Responsive — Mobile sidebar
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .navbar {
        left: 0;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 80;
    }
    .sidebar-overlay.active {
        display: block;
    }
}

/* ============================================================
   Animated Modal System  (mirrors Gratus Investments style)
   Wrapper: .modal-overlay  (hidden by default)
   Card:    .modal-panel
   Open:    call openModal(id)  → adds .modal-open
   Close:   call closeModal(id) → removes .modal-open, then hides
   ============================================================ */

/* Backdrop */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,0);
    transition: background 0.22s ease;
    overflow-y: auto;
}
.modal-overlay.modal-open {
    background: rgba(0,0,0,0.5);
}

/* Card — starts invisible + slightly above */
.modal-panel {
    position: relative;
    background: #fff;
    border-radius: 16px;          /* rounded-2xl */
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
    width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    /* initial state */
    opacity: 0;
    transform: scale(0.94) translateY(-14px);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity   0.22s ease;
}
.modal-overlay.modal-open .modal-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Sizes */
.modal-sm  { max-width: 400px;  }
.modal-md  { max-width: 560px;  }
.modal-lg  { max-width: 760px;  }
.modal-xl  { max-width: 1000px; }

/* ── GI-style modal button pair ── */
/* Cancel: red border, fills red on hover */
.btn-modal-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border-radius: 8px;
    border: 2px solid #ef4444;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
    background: transparent;
    white-space: nowrap;
}
.btn-modal-cancel:hover {
    background: #ef4444;
    color: #fff;
}

/* Confirm: blue border, fills blue on hover (accounting brand) */
.btn-modal-confirm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 8px;
    border: 2px solid #2563eb;
    color: #1d4ed8;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
    background: transparent;
    white-space: nowrap;
}
.btn-modal-confirm:hover {
    background: #2563eb;
    color: #fff;
}

/* Green variant for payment/success actions */
.btn-modal-confirm.green {
    border-color: #16a34a;
    color: #15803d;
}
.btn-modal-confirm.green:hover {
    background: #16a34a;
    color: #fff;
}

/* ============================================================
   Chart Period Selector (TradingView-style)
   ============================================================ */
.period-btn {
    cursor: pointer;
    border: none;
    outline: none;
    background: transparent;
    line-height: 1;
}
.period-btn.active-period {
    background: #fff;
    color: #2563eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    border-radius: 6px;
}
