/* dashboard.css — Lawyer Dashboard styles */
/* Adapted from old lawyer_dashboard.html inline styles */

.lawyer-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    direction: rtl;
}

body[dir="ltr"] .lawyer-dashboard {
    direction: ltr;
}

/* ── Top Header (logo + nav) ── */
.dashboard-top-header {
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 24px;
}

.dashboard-top-header .header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-top-header .logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.dashboard-top-header .header-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.dashboard-top-header .header-titles {
    display: flex;
    flex-direction: column;
}

.dashboard-top-header .title-ar {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
}

.dashboard-top-header .title-en {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.dashboard-top-header .header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dashboard-top-header .header-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.dashboard-top-header .header-link:hover {
    color: var(--primary);
}

.dashboard-top-header .user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* ── Dashboard Header (green banner) ── */
.dashboard-header {
    background: var(--primary);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin: 20px 20px 30px;
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    margin: 0;
}

/* Stats Row */
.stats-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 0 20px;
}

.stat-card {
    flex: 1;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Filters */
.filters-section {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    margin: 0 20px 20px;
    border: 1px solid var(--border-light);
}

.filter-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-family: var(--font-ar), var(--font-en), sans-serif;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Cases Grid */
.cases-grid {
    display: grid;
    gap: 20px;
    padding: 0 20px;
}

.case-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: border-color 0.2s;
    cursor: pointer;
}

.case-card:hover {
    border-color: var(--border-default);
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.case-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.case-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Status badges */
.status-draft { background: #fef3c7; color: #92400e; }
.status-submitted { background: var(--focus-ring); color: var(--primary); }
.status-pending_review { background: #dbeafe; color: #1e40af; }
.status-reviewed { background: #d1fae5; color: var(--success); }
.status-approved { background: #d1fae5; color: var(--success); }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-needs_info { background: #fef3c7; color: #92400e; }
.status-closed { background: var(--bg-section); color: var(--text-secondary); }

.case-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.info-item {
    font-size: 0.9rem;
}

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

.info-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Flags */
.flags-section {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
}

.flag-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.red-flags { background: #fee2e2; color: #991b1b; }
.warnings { background: #fef3c7; color: #92400e; }
.no-flags { background: #d1fae5; color: var(--success); }

/* Score badges */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.score-high { background: #d1fae5; color: #059669; }
.score-medium { background: #fef3c7; color: #d97706; }
.score-low { background: #fee2e2; color: #dc2626; }

.validity-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.validity-valid { background: #d1fae5; color: #059669; }
.validity-needs_review { background: #fef3c7; color: #d97706; }
.validity-invalid { background: #fee2e2; color: #dc2626; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-card);
    max-width: 1200px;
    margin: 50px auto;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    position: relative;
}

.modal-header {
    background: var(--primary);
    color: white;
    padding: 20px 30px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    background: var(--bg-section);
    border-radius: 0 0 8px 8px;
}

/* Detail sections */
.detail-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

/* Score section */
.score-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #0ea5e9;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

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

.score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.score-circle.high { background: linear-gradient(135deg, #059669, #10b981); }
.score-circle.medium { background: linear-gradient(135deg, #d97706, #f59e0b); }
.score-circle.low { background: linear-gradient(135deg, #dc2626, #ef4444); }

.score-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.score-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.score-item-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.score-item-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Viability */
.viability-section {
    background: var(--bg-section);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.viability-reasons {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.viability-reasons li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.viability-reasons li::before {
    content: "\2022";
    color: var(--primary);
    font-weight: bold;
}

/* Fees */
.fees-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
}

.fees-total {
    font-size: 2rem;
    font-weight: 700;
    color: #92400e;
    text-align: center;
    margin-bottom: 15px;
}

.fees-breakdown {
    background: white;
    border-radius: 8px;
    padding: 15px;
}

.fees-breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.fees-breakdown-row:last-child {
    border-bottom: none;
}

/* Claims */
.claim-card {
    background: var(--bg-section);
    padding: 15px;
    border-radius: 6px;
    border-right: 3px solid var(--primary);
    margin-bottom: 15px;
}

body[dir="ltr"] .claim-card {
    border-right: none;
    border-left: 3px solid var(--primary);
}

.claim-type {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.claim-amounts {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.amount-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.claim-note {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    font-size: 0.9rem;
    color: #92400e;
}

.claim-viable {
    border-right-color: #059669;
}

.claim-not-viable {
    border-right-color: #dc2626;
    opacity: 0.7;
}

/* Flag cards */
.flag-card {
    background: #fee2e2;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #dc2626;
}

.flag-card.warning {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

/* Recommendation */
.recommendation-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #3b82f6;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.recommendation-title {
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.recommendation-text {
    color: #1e3a8a;
    line-height: 1.6;
}

/* Missing fields */
.missing-fields {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.missing-fields-title {
    font-weight: 700;
    color: #991b1b;
    margin-bottom: 10px;
}

.missing-field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    color: #7f1d1d;
}

/* Files */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.file-card {
    background: var(--bg-section);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

a.file-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

a.file-card-link:hover {
    background: #e8f5e9;
    box-shadow: 0 2px 8px rgba(0,107,60,0.1);
}

.file-download-icon {
    margin-inline-start: auto;
    font-size: 1.1rem;
    color: var(--adl-green);
    opacity: 0.6;
}

a.file-card-link:hover .file-download-icon {
    opacity: 1;
}

.file-icon {
    font-size: 1.5rem;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-all;
}

.file-type {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Loading / Empty */
.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* Dashboard-specific buttons */
.btn-approve { background: #059669; color: white; }
.btn-approve:hover { background: #047857; }

.btn-reject { background: #dc2626; color: white; }
.btn-reject:hover { background: #b91c1c; }

.btn-request-info { background: #f59e0b; color: white; }
.btn-request-info:hover { background: #d97706; }

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

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

/* Badge helpers (for contract validation) */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #059669; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-secondary { background: var(--bg-section); color: var(--text-secondary); }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ── Summary groups ── */
.summary-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.summary-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.summary-group-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0369a1;
    margin: 0 0 12px 0;
    padding-right: 10px;
    border-right: 3px solid #0ea5e9;
}

body[dir="ltr"] .summary-group-title {
    padding-right: 0;
    padding-left: 10px;
    border-right: none;
    border-left: 3px solid #0ea5e9;
}

/* ── Comparison table ── */
.comparison-banner {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.comparison-banner-ok { background: #d1fae5; color: #059669; }
.comparison-banner-warn { background: #fef3c7; color: #92400e; }

.comparison-table {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.7fr;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-section);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.comparison-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.7fr;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
}

.comparison-row:last-child { border-bottom: none; }
.comparison-mismatch { background: #fefce8; }
.comparison-label { font-weight: 600; color: var(--text-primary); }

/* ── Calculation breakdown ── */
.calc-breakdown {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 10px 0;
}

.calc-breakdown-title {
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.calc-breakdown-formula {
    font-family: var(--font-mono);
    color: #1e293b;
    font-size: 0.9rem;
    line-height: 1.6;
    direction: ltr;
    text-align: left;
}

.calc-breakdown-legal {
    color: #1e40af;
    font-size: 0.85rem;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
}

/* ── Claims amounts grid ── */
.claim-amounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.claim-amount-box {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.claim-amount-matched {
    border-color: #86efac;
    background: #f0fdf4;
}

.claim-amount-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.claim-amount-value {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.claim-amount-matched .claim-amount-value { color: #059669; }

/* ── Claims totals ── */
.claims-totals {
    background: #f0fdf4;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.claims-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-weight: 600;
    border-bottom: 1px solid #d1fae5;
}

.claims-totals-row:last-child { border-bottom: none; }

/* ── Eligible amount calculation rows ── */
.eligible-calc-row {
    padding: 12px;
    margin-bottom: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.eligible-calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.eligible-calc-type {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.eligible-calc-amount {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.eligible-calc-formula {
    font-family: var(--font-mono);
    color: #1e293b;
    font-size: 0.88rem;
    line-height: 1.6;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    direction: ltr;
    text-align: left;
    margin-top: 4px;
}

.eligible-calc-legal {
    color: #1e40af;
    font-size: 0.82rem;
    margin-top: 6px;
}

.claims-totals-matched {
    padding-top: 12px;
    margin-top: 4px;
    border-top: 2px solid #86efac;
    color: #059669;
    font-weight: 700;
    font-size: 1.05rem;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-top-header .header-inner {
        flex-wrap: wrap;
        gap: 8px;
    }
    .dashboard-top-header .header-nav {
        gap: 8px;
        flex-wrap: wrap;
    }
    .dashboard-top-header .header-link {
        font-size: 0.8rem;
    }
    .dashboard-header {
        margin: 10px 10px 20px;
        padding: 20px;
    }
    .stats-row {
        flex-direction: column;
        padding: 0 10px;
    }
    .filters-section {
        margin: 0 10px 20px;
    }
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    .cases-grid {
        padding: 0 10px;
    }
    .modal-content {
        margin: 20px;
    }
    .modal-body {
        padding: 15px;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .score-details {
        grid-template-columns: 1fr;
    }
    .comparison-header, .comparison-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .comparison-header { display: none; }
    .comparison-row { padding: 12px; }
    .comparison-label { margin-bottom: 4px; }
    .claim-amounts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .dashboard-top-header .header-titles {
        display: none;
    }
    .dashboard-top-header .header-logo-img {
        width: 36px;
        height: 36px;
    }
}
