/* ============================================
   CRDB Bank Tanzania PLC - DIA KPI System
   Professional Dashboard Stylesheet
   ============================================ */

:root {
    --crdb-green: #006341;
    --crdb-green-dark: #004d32;
    --crdb-green-light: #e6f2ed;
    --crdb-gold: #c9a227;
    --crdb-gold-light: #f9f3e0;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #6b6b8a;
    --border-color: #e2e8f0;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-header: #006341;
    --error-red: #dc2626;
    --error-bg: #fef2f2;
    --success-green: #059669;
    --success-bg: #ecfdf5;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--crdb-green-dark) 0%, var(--crdb-green) 100%);
    padding: 20px;
}

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

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    width: 64px;
    height: 64px;
    background: var(--crdb-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    margin: 0 auto 16px;
    letter-spacing: 1px;
}

.login-brand h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.brand-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.brand-divider {
    width: 48px;
    height: 3px;
    background: var(--crdb-gold);
    margin: 16px auto;
    border-radius: 2px;
}

.login-brand h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
}

input[type="number"] {
    padding-left: 14px;
}

input:focus {
    outline: none;
    border-color: var(--crdb-green);
    box-shadow: 0 0 0 3px rgba(0, 99, 65, 0.1);
}

input::placeholder {
    color: #94a3b8;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--crdb-green);
    color: white;
}

.btn-primary:hover {
    background: var(--crdb-green-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-body);
    border-color: var(--text-muted);
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.25);
}

.btn-submit {
    padding: 14px 28px;
    font-size: 15px;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-red);
    border: 1px solid #fecaca;
}

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

.login-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.login-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.login-footer code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

.security-note {
    font-size: 11px !important;
    font-style: italic;
    margin-top: 8px;
}

/* ============================================
   DASHBOARD PAGE
   ============================================ */

.app-header {
    background: var(--crdb-green);
    color: white;
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    background: white;
    color: var(--crdb-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-titles h1 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--crdb-gold);
    color: var(--crdb-green-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    opacity: 0.8;
}

.main-content {
    padding: 28px 32px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Info Card */
.info-card {
    background: var(--crdb-green-light);
    border: 1px solid #b8d8c8;
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.info-icon {
    color: var(--crdb-green);
    flex-shrink: 0;
    margin-top: 2px;
}

.info-content h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--crdb-green-dark);
    margin-bottom: 4px;
}

.info-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-content strong {
    color: var(--crdb-green);
}

/* Table Styles */
.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    margin-bottom: 20px;
}

.kpi-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    min-width: 1400px;
}

.kpi-table thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.kpi-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

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

.kpi-table tbody tr:hover {
    background: #f8fafc;
}

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

/* Column Widths */
.col-num { width: 40px; text-align: center; }
.col-code { width: 140px; }
.col-main { min-width: 280px; }
.col-index { min-width: 220px; }
.col-sub { min-width: 160px; }
.col-scale { width: 100px; }
.col-unit { width: 90px; }
.col-dept { width: 90px; }
.col-target { width: 120px; }
.col-actual { width: 120px; }
.col-date { width: 140px; }
.col-role { width: 130px; }

.cell-num {
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
}

/* Readonly Fields */
.readonly-field {
    display: block;
    color: var(--text-secondary);
    line-height: 1.4;
}

.code-field {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--crdb-green);
    background: var(--crdb-green-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.null-value {
    color: #94a3b8;
    font-style: italic;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--crdb-green-light);
    color: var(--crdb-green);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-secondary {
    background: #f1f5f9;
    color: var(--text-secondary);
}

.badge-role {
    background: var(--crdb-gold-light);
    color: #856d1a;
}

.date-field {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Editable Fields */
.editable-field {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
}

.editable-field:focus {
    outline: none;
    border-color: var(--crdb-green);
    box-shadow: 0 0 0 3px rgba(0, 99, 65, 0.15);
    background: #fff;
}

.editable-field::placeholder {
    color: #cbd5e1;
    text-align: right;
}

/* Form Actions */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 18px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.records-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.action-right {
    display: flex;
    gap: 12px;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 24px 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

.app-footer p {
    font-size: 12px;
    color: var(--text-muted);
}

.footer-system {
    margin-top: 4px;
    font-size: 11px !important;
    opacity: 0.7;
}

/* Spinner */
.spinner {
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0 16px;
        height: auto;
        flex-direction: column;
        padding-top: 12px;
        padding-bottom: 12px;
        gap: 10px;
    }

    .main-content {
        padding: 16px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .form-actions {
        flex-direction: column;
        gap: 16px;
    }

    .action-right {
        width: 100%;
        justify-content: stretch;
    }

    .action-right .btn {
        flex: 1;
    }
}

/* Print styles */
@media print {
    .app-header,
    .info-card,
    .form-actions,
    .app-footer {
        display: none !important;
    }

    .editable-field {
        border: none;
        background: transparent;
    }
}
