/* ETS Portal base styles
 * Based on DESIGN_SYSTEM.md and design_example.html
 * Flat, clean UI with brand colors and Tailwind-like utilities.
 */

/* =========================
   CSS Custom Properties
   ========================= */
:root {
    /* Brand Colors */
    --color-primary: #002663;
    --color-secondary: #FFE600;

    /* Semantic Colors */
    --color-success: #16A34A;
    --color-warning: #F59E0B;
    --color-error: #DC2626;
    --color-info: #3B82F6;

    /* Neutral Colors */
    --color-gray-50: #F9FAFB;
    --color-gray-100: #F3F4F6;
    --color-gray-200: #E5E7EB;
    --color-gray-300: #D1D5DB;
    --color-gray-400: #9CA3AF;
    --color-gray-500: #6B7280;
    --color-gray-600: #4B5563;
    --color-gray-700: #374151;
    --color-gray-800: #1F2937;
    --color-gray-900: #111827;

    /* Text Colors */
    --text-primary: var(--color-gray-900);
    --text-secondary: var(--color-gray-700);
    --text-muted: var(--color-gray-500);

    /* Background Colors */
    --bg-primary: var(--color-gray-50);
    --bg-secondary: #ffffff;

    /* Border Colors */
    --border-primary: var(--color-gray-300);

    /* Badge Background Colors */
    --badge-success-bg: #BBF7D0;
    --badge-warning-bg: #FEF08A;
    --badge-error-bg: #FECACA;
    --badge-info-bg: #BFDBFE;

    /* Badge Text Colors */
    --badge-success-text: #065F46;
    --badge-warning-text: #92400E;
    --badge-error-text: #991B1B;
    --badge-info-text: #1E40AF;

    /* Focus */
    --focus-ring: #93C5FD; /* blue-300 */
}

/* Layout helpers */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.mx-auto { margin-left: auto; margin-right: auto; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* Typography */
h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
}

.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-lg  { font-size: 1.125rem; line-height: 1.75rem; }
.text-sm  { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs  { font-size: 0.75rem; line-height: 1rem; }

.font-semibold { font-weight: 600; }
.font-medium   { font-weight: 500; }

.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.08em; }

.text-slate-50  { color: #f8fafc; }
.text-slate-300 { color: #cbd5f5; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-slate-900 { color: #0f172a; }
.text-emerald-600 { color: #059669; }
.text-amber-700 { color: #b45309; }

/* Header / top-nav */
.bg-slate-900 { background-color: var(--color-primary); }
.bg-white     { background-color: #ffffff; }
.bg-slate-50  { background-color: var(--bg-primary); }
.border-slate-200 { border-color: var(--color-gray-200); }
.border-slate-700 { border-color: var(--color-gray-700); }

a {
    color: #0f172a;
    text-decoration: none;
}

a.link {
    color: #1d4ed8; /* blue-700 */
    text-decoration: underline;
}

a:hover {
    text-decoration: underline;
}

header a {
    color: #e5e7eb;
    text-decoration: none;
}

header a:hover {
    text-decoration: underline;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Focus ring for keyboard users */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Cards */
.card {
    background-color: #ffffff;
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    overflow: hidden;
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.card-body {
    padding: 0.75rem 1rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: #6b7280;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.9rem;
    border-radius: 0.375rem;
    border-width: 1px;
    border-style: solid;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    background-color: transparent;
}

.btn-primary {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
    color: var(--text-primary);
}

.btn-primary:hover {
    background-color: #111827;
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-primary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-ghost {
    border-color: transparent;
    color: #374151;
}

.btn-ghost:hover {
    background-color: #e5e7eb;
}

/* Forms */
.form-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #4b5563;
}

.form-input,
select.form-input,
textarea.form-input {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e1;
    font-size: 0.875rem;
    color: #0f172a;
    background-color: var(--bg-secondary);
    border-color: var(--border-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 38, 99, 0.1);
}

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

.table th,
.table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.table thead th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #ffffff;
    background-color: var(--color-primary);
}

.table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

/* Badges */
.badge-success,
.badge-warning,
.badge-muted {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: var(--badge-success-bg);
    color: var(--badge-success-text);
}

.badge-warning {
    background-color: var(--badge-warning-bg);
    color: var(--badge-warning-text);
}

.badge-muted {
    background-color: var(--color-gray-200);
    color: var(--color-gray-700);
}

.tab-btn {
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: block;
}

.tab-content[hidden] {
    display: none !important;
}

/* Simple responsive grid helpers (used in prototypes) */
@media (min-width: 768px) {
    .md\\:flex-row { flex-direction: row; }
    .md\\:items-center { align-items: center; }
    .md\\:justify-between { justify-content: space-between; }
    .md\\:grid-cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); }
    .md\\:grid-cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
}

@media (min-width: 1024px) {
    .lg\\:grid-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
    .lg\\:col-span-2 { grid-column: span 2 / span 2; }
    .lg\\:col-span-3 { grid-column: span 3 / span 3; }
}

/* Modal styles (used by project detail prototypes) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s ease-in-out;
}

/* Wider modal (e.g. CER reporting detail) */
.modal-container.modal-container--wide {
    max-width: min(960px, 96vw);
    width: 96%;
}

.modal-overlay:not(.hidden) .modal-container {
    transform: scale(1);
}

.modal-content {
    display: flex;
    flex-direction: column;
}

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

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-secondary);
}

.modal-cancel-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
}

.modal-cancel-btn:hover {
    background-color: var(--color-gray-100);
}

.modal-save-btn {
    padding: 0.5rem 1rem;
    background-color: var(--color-secondary);
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
}

.modal-save-btn:hover {
    background-color: #FFD700;
}