@import url('/static/css/fonts.css');

:root {
    --bg-main: #eef2f6;
    --surface-card: #ffffff;
    --table-header-bg: #1e293b;
    --table-border: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary-indigo: #312e81;
    --accent-teal: #0d9488;
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    padding-bottom: 3.5rem;
}

html[dir="ltr"] body { direction: ltr; text-align: left; }
html[dir="rtl"] body { direction: rtl; text-align: right; }

/* Distinct Modern Dark Slate & Teal Header */
.top-hero-banner {
    background: linear-gradient(120deg, #0f172a 0%, #1e1b4b 55%, #115e59 100%);
    color: #ffffff;
    padding: 2.2rem 1rem;
    border-bottom: 4px solid #14b8a6;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-hero-banner h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }

.header-actions { display: flex; gap: 0.75rem; align-items: center; }

.btn-top {
    padding: 0.5rem 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 90px;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
}
.btn-top:hover { background: rgba(255, 255, 255, 0.25); }

.btn-print { background: #14b8a6; color: #0f172a; border: none; font-weight: 700; }
.btn-print:hover { background: #2dd4bf; }

.report-container {
    max-width: 1080px;
    margin: 1.75rem auto;
    padding: 0 1rem;
}

/* Search Box */
.search-container {
    background: var(--surface-card);
    border: 1px solid var(--table-border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.search-form { display: flex; gap: 0.75rem; }
.search-form input {
    flex: 1;
    padding: 0.8rem 1.1rem;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    direction: ltr;
    text-align: left;
    transition: border-color 0.2s;
}
.search-form input:focus { outline: none; border-color: #0d9488; }

.btn-scan {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 2rem;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn-scan:hover { opacity: 0.92; }

/* Spinner */
.spinner {
    width: 44px; height: 44px;
    border: 4px solid #cbd5e1; border-top: 4px solid #0d9488;
    border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Summary Card */
.summary-top-card {
    background: var(--surface-card);
    border: 1px solid var(--table-border);
    border-radius: 12px;
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.score-circle-wrapper { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.score-circle {
    width: 130px; height: 130px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%; color: #ffffff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}
.score-circle .grade { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-circle .numeric { font-size: 0.95rem; font-weight: 700; margin-top: 5px; }

.summary-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: center;
}

/* Quality Bar Chart */
.chart-box { border-left: 1px solid #e2e8f0; padding-left: 1.5rem; text-align: center; }
html[dir="rtl"] .chart-box { border-left: none; border-right: 1px solid #e2e8f0; padding-left: 0; padding-right: 1.5rem; }
.chart-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 1.25rem; color: #1e293b; }

.chart-container-exact {
    display: flex; align-items: stretch; height: 180px; margin: 0 auto; position: relative; max-width: 440px;
}
.chart-y-axis {
    display: flex; flex-direction: column; justify-content: space-between;
    padding-right: 8px; font-size: 0.75rem; font-weight: 600; color: #64748b; text-align: right; width: 32px;
}
html[dir="rtl"] .chart-y-axis { padding-right: 0; padding-left: 8px; text-align: left; }

.chart-plot-area {
    flex: 1; position: relative; border-left: 1px solid #94a3b8; border-bottom: 1px solid #94a3b8;
    display: flex; justify-content: space-around; align-items: flex-end; padding: 0 4px;
}
html[dir="rtl"] .chart-plot-area { border-left: none; border-right: 1px solid #94a3b8; }

.chart-grid-lines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.grid-line { width: 100%; border-bottom: 1px dashed #e2e8f0; }
.grid-line:last-child { border-bottom: none; }

.bar-col-exact { display: flex; flex-direction: column; align-items: center; width: 16%; height: 100%; justify-content: flex-end; position: relative; z-index: 2; }
.bar-fill-exact { width: 100%; min-height: 2px; background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%); border-radius: 4px 4px 0 0; transition: height 0.9s ease; }
.bar-percent-label { position: absolute; top: -18px; font-size: 0.7rem; font-weight: 700; color: #0f766e; }

.chart-x-labels { display: flex; justify-content: space-around; margin-left: 32px; margin-top: 8px; max-width: 440px; }
html[dir="rtl"] .chart-x-labels { margin-left: 0; margin-right: 32px; }
.x-label-item { width: 16%; font-size: 0.75rem; font-weight: 600; color: #475569; text-align: center; white-space: nowrap; }

/* Report Cards */
.report-section {
    background: var(--surface-card);
    border: 1px solid var(--table-border);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.section-header {
    background: var(--table-header-bg);
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.3px;
}

.table-custom { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.meta-table { border: 1px solid #e2e8f0; }
.meta-header { background: #f8fafc; font-weight: 600; padding: 0.45rem 1rem; color: #334155; }
.meta-content { padding: 0.45rem 1rem; color: #0f172a; font-weight: 500; }

.table-custom tr { border-bottom: 1px solid #e2e8f0; }
.table-custom tr:last-child { border-bottom: none; }
.table-custom td, .table-custom th { padding: 0.7rem 1rem; vertical-align: middle; }

.table-custom .col-label { width: 36%; color: #1e293b; font-weight: 600; }
.table-custom .col-icon { width: 6%; text-align: center; }
.table-custom .col-value { color: #0f172a; font-weight: 500; }

/* =====================================================================
   Protocol Security Gradient (Light Red -> Light Orange -> Light Yellow -> Light Green)
   ===================================================================== */
.proto-row-ssl2 { background-color: #fef2f2 !important; border-left: 5px solid #ef4444; } /* Critical Danger - Light Red */
.proto-row-ssl3 { background-color: #fff1f2 !important; border-left: 5px solid #f43f5e; } /* High Danger - Soft Rose */
.proto-row-tls10 { background-color: #fff7ed !important; border-left: 5px solid #f97316; } /* Legacy Warning - Light Orange */
.proto-row-tls11 { background-color: #fefce8 !important; border-left: 5px solid #eab308; } /* Deprecated Caution - Light Yellow */
.proto-row-tls12 { background-color: #f0fdf4 !important; border-left: 5px solid #22c55e; } /* Secure Standard - Light Green */
.proto-row-tls13 { background-color: #ecfdf5 !important; border-left: 5px solid #10b981; } /* Maximum Security - Mint Green */

html[dir="rtl"] .proto-row-ssl2 { border-left: none; border-right: 5px solid #ef4444; }
html[dir="rtl"] .proto-row-ssl3 { border-left: none; border-right: 5px solid #f43f5e; }
html[dir="rtl"] .proto-row-tls10 { border-left: none; border-right: 5px solid #f97316; }
html[dir="rtl"] .proto-row-tls11 { border-left: none; border-right: 5px solid #eab308; }
html[dir="rtl"] .proto-row-tls12 { border-left: none; border-right: 5px solid #22c55e; }
html[dir="rtl"] .proto-row-tls13 { border-left: none; border-right: 5px solid #10b981; }

/* Status Icons */
.icon-ok { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: #10b981; color: #fff; border-radius: 50%; font-size: 12px; }
.icon-warn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: #f59e0b; color: #fff; border-radius: 50%; font-size: 12px; }
.icon-bad { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: #ef4444; color: #fff; border-radius: 50%; font-size: 12px; }

.text-success-desc { color: #047857; font-size: 0.88rem; }
.text-danger-desc { color: #b91c1c; font-size: 0.88rem; }
.text-warning-desc { color: #b45309; font-size: 0.88rem; }

/* Status Pills */
.status-pill { padding: 0.25rem 0.65rem; border-radius: 6px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; display: inline-block; }
.pill-pass { background: rgba(16, 185, 129, 0.15); color: #047857; border: 1px solid #10b981; }
.pill-fail { background: rgba(239, 68, 68, 0.15); color: #b91c1c; border: 1px solid #ef4444; }
.pill-warn { background: rgba(245, 158, 11, 0.15); color: #b45309; border: 1px solid #f59e0b; }

/* Standards 8-Card Grid */
.standards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
    background: #f8fafc;
}
.standard-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 1.1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    transition: transform 0.2s;
}
.standard-card:hover { transform: translateY(-2px); }
.standard-card h3 { font-size: 0.95rem; font-weight: 700; color: #1e293b; margin-bottom: 0.5rem; }
.standard-badge-val { font-size: 1.5rem; font-weight: 800; margin: 0.4rem 0; }
.standard-desc-list { text-align: left; font-size: 0.78rem; color: #475569; list-style: none; margin-top: 0.6rem; padding: 0; }
html[dir="rtl"] .standard-desc-list { text-align: right; }
.standard-desc-list li { margin-bottom: 0.25rem; padding-left: 0.85rem; position: relative; }
html[dir="rtl"] .standard-desc-list li { padding-left: 0; padding-right: 0.85rem; }
.standard-desc-list li::before { content: "•"; position: absolute; left: 0; color: #0d9488; font-weight: bold; }
html[dir="rtl"] .standard-desc-list li::before { left: auto; right: 0; }

@media (max-width: 768px) {
    .header-flex { flex-direction: column; text-align: center; gap: 1rem; }
    .summary-grid { grid-template-columns: 1fr; }
    .chart-box { border: none !important; padding: 0 !important; margin-bottom: 1.5rem; }
}

@media print {
    .no-print { display: none !important; }
    body { background: #fff !important; padding: 0 !important; }
    .report-section, .summary-top-card, .proto-row-ssl2, .proto-row-ssl3, .proto-row-tls10, .proto-row-tls11, .proto-row-tls12, .proto-row-tls13 {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
