/* ============================================================
   FinOps CRM - Main Stylesheet
   Theme: EasyLedger Blue
   ============================================================ */

/* ---------- CSS VARIABLES ---------- */
:root {
    --primary:        #1a56db;
    --primary-dark:   #1246b8;
    --primary-light:  #3b82f6;
    --primary-bg:     #eff6ff;
    --primary-50:     #eff6ff;
    --primary-100:    #dbeafe;
    --primary-200:    #bfdbfe;
    --primary-500:    #3b82f6;
    --primary-600:    #2563eb;
    --primary-700:    #1d4ed8;
    --primary-800:    #1e40af;
    --primary-900:    #1e3a8a;

    --success:        #10b981;
    --success-bg:     #ecfdf5;
    --warning:        #f59e0b;
    --warning-bg:     #fffbeb;
    --danger:         #ef4444;
    --danger-bg:      #fef2f2;
    --info:           #06b6d4;
    --info-bg:        #ecfeff;

    --gray-50:        #f9fafb;
    --gray-100:       #f3f4f6;
    --gray-200:       #e5e7eb;
    --gray-300:       #d1d5db;
    --gray-400:       #9ca3af;
    --gray-500:       #6b7280;
    --gray-600:       #4b5563;
    --gray-700:       #374151;
    --gray-800:       #1f2937;
    --gray-900:       #111827;

    --white:          #ffffff;
    --body-bg:        #f0f4f8;
    --card-bg:        #ffffff;
    --border-color:   #e5e7eb;
    --text-primary:   #1f2937;
    --text-secondary: #6b7280;
    --text-muted:     #9ca3af;

    --sidebar-width:  260px;
    --header-height:  60px;
    --radius:         8px;
    --radius-lg:      12px;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
    --shadow:         0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --transition:     all 0.2s ease;

    --font-family:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

img { max-width: 100%; }

/* ---------- TYPOGRAPHY ---------- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-800);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Button loading spinner */
.btn .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-50); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 8px; }

/* ---------- FORM ELEMENTS ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: var(--transition);
    line-height: 1.4;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

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

.form-control.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.form-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 3px;
}

/* ---------- PASSWORD TOGGLE ---------- */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 1rem;
    padding: 4px;
}

.password-toggle:hover {
    color: var(--gray-600);
}

/* ---------- CARDS ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- ALERTS ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-bg);    color: #155e75; border: 1px solid #a5f3fc; }

.alert .alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: inherit;
    opacity: 0.6;
}

.alert .alert-close:hover { opacity: 1; }

/* ---------- BADGES ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-100); color: var(--primary-800); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #cffafe; color: #155e75; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ---------- STAR RATING ---------- */
.star-rating {
    display: inline-flex;
    gap: 2px;
}

.star-rating .star {
    cursor: pointer;
    color: var(--gray-300);
    font-size: 1rem;
    transition: var(--transition);
}

.star-rating .star.active,
.star-rating .star:hover {
    color: var(--warning);
}

/* ---------- TABLE ---------- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

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

table thead {
    background: var(--gray-50);
}

table th {
    padding: 10px 14px;
    font-weight: 600;
    color: var(--gray-600);
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table tbody tr:hover {
    background: var(--primary-50);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- PAGINATION ---------- */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 0.83rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-controls button {
    padding: 6px 10px;
    font-size: 0.83rem;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    min-width: 32px;
}

.pagination-controls button:hover:not(:disabled) {
    background: var(--primary-50);
    border-color: var(--primary-500);
    color: var(--primary);
}

.pagination-controls button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-size {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-size label {
    font-size: 0.83rem;
    color: var(--text-secondary);
}

.pagination-size select {
    padding: 4px 24px 4px 8px;
    font-size: 0.83rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
}

/* ---------- SEARCHABLE DROPDOWN ---------- */
.searchable-dropdown {
    position: relative;
}

.searchable-dropdown .sd-input {
    width: 100%;
    padding: 9px 32px 9px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
}

.searchable-dropdown .sd-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.searchable-dropdown .sd-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--gray-400);
    font-size: 0.75rem;
}

.searchable-dropdown .sd-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
}

.searchable-dropdown.open .sd-menu {
    display: block;
}

.searchable-dropdown .sd-option {
    padding: 8px 12px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.1s;
}

.searchable-dropdown .sd-option:hover,
.searchable-dropdown .sd-option.highlighted {
    background: var(--primary-50);
    color: var(--primary);
}

.searchable-dropdown .sd-option.selected {
    background: var(--primary-100);
    font-weight: 500;
}

.searchable-dropdown .sd-no-results {
    padding: 12px;
    font-size: 0.83rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- TOAST / SNACKBAR ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: #065f46; color: white; }
.toast-error   { background: #991b1b; color: white; }
.toast-warning { background: #92400e; color: white; }
.toast-info    { background: #155e75; color: white; }

.toast.removing {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }


/* ============================================================
   LOGIN / REGISTER PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-700) 50%, var(--primary-500) 100%);
    padding: 20px;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo h1 {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-logo h1 i {
    margin-right: 8px;
    font-size: 1.5rem;
}

.login-logo p {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-100);
}

.login-tab {
    flex: 1;
    padding: 14px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-500);
    background: var(--gray-50);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.login-tab.active {
    color: var(--primary);
    background: var(--white);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

.login-tab:hover:not(.active) {
    background: var(--gray-100);
}

.login-body {
    padding: 28px;
}

.login-form { display: none; }
.login-form.active { display: block; }

.login-footer {
    text-align: center;
    padding: 16px 28px;
    background: var(--gray-50);
    border-top: 1px solid var(--border-color);
}

.login-footer a {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ---------- MODAL ---------- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

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

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--gray-700); }

.modal-body {
    padding: 20px;
}

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

/* ---------- UTILITY CLASSES ---------- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-primary { color: var(--primary); }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.hidden { display: none !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    html { font-size: 13px; }

    .login-container { max-width: 100%; }
    .login-body { padding: 20px; }

    .pagination-wrapper {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .pagination-controls {
        justify-content: center;
    }

    table { font-size: 0.8rem; }
    table th, table td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .login-logo h1 { font-size: 1.5rem; }
    .login-body { padding: 16px; }
    .btn { padding: 8px 12px; font-size: 0.83rem; }
}
