/**
 * AALIM PTC Platform â Base Stylesheet
 *
 * All colors reference CSS custom properties set by the Theme engine.
 * This file contains NO hardcoded colors â everything adapts to the
 * active theme automatically.
 *
 * CSS variables are injected by Theme::styleTag() in <head>.
 */

/* ââ Reset & Base ââââââââââââââââââââââââââââââââ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--accent-hover);
}

/* ââ Layout ââââââââââââââââââââââââââââââââââââââ */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.page-main {
    flex-grow: 1;
}

/* ââ Header ââââââââââââââââââââââââââââââââââââââ */
.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header .nav-link {
    color: var(--text-secondary);
    transition: color 0.2s;
}
.site-header .nav-link:hover,
.site-header .nav-link.active {
    color: var(--accent);
}

/* ââ Cards âââââââââââââââââââââââââââââââââââââââ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow), 0 8px 32px rgba(0,0,0,0.1);
}
.card-static {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
}

/* ââ Buttons âââââââââââââââââââââââââââââââââââââ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to));
    color: #ffffff;
}
.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    color: #ffffff;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}
.btn-danger:hover {
    opacity: 0.9;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}

/* ââ Form Inputs âââââââââââââââââââââââââââââââââ */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input::placeholder {
    color: var(--text-muted);
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

/* ââ Tables ââââââââââââââââââââââââââââââââââââââ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.875rem;
}
.data-table tr:hover td {
    background: var(--bg-hover);
}
.data-table tr:last-child td {
    border-bottom: none;
}

/* ââ Badges ââââââââââââââââââââââââââââââââââââââ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-accent {
    background: var(--accent-light);
    color: var(--accent);
}
.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}
.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}
.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ââ Alerts / Notices ââââââââââââââââââââââââââââ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
}
.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--success);
}
.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}
.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--warning);
}
.alert-info {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ââ Stats / Metric Cards ââââââââââââââââââââââââ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}
.stat-accent {
    color: var(--accent);
}

/* ââ Gradient Accent âââââââââââââââââââââââââââââ */
.gradient-accent {
    background: linear-gradient(135deg, var(--gradient-from) 0%, var(--gradient-to) 100%);
}
.gradient-text {
    background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ââ Progress Bar ââââââââââââââââââââââââââââââââ */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-hover);
    border-radius: 9999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-from), var(--gradient-to));
    border-radius: 9999px;
    transition: width 0.6s ease;
}

/* ââ Footer ââââââââââââââââââââââââââââââââââââââ */
.site-footer {
    background: var(--header-bg);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}
.site-footer a {
    color: var(--text-muted);
}
.site-footer a:hover {
    color: var(--accent);
}

/* ââ Utility âââââââââââââââââââââââââââââââââââââ */
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.bg-primary   { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-card      { background-color: var(--bg-card) !important; }

.border-theme { border-color: var(--border) !important; }

/* Scrollbar theming (WebKit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ââ Animations ââââââââââââââââââââââââââââââââââ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes pulse-accent {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-light); }
    50%      { box-shadow: 0 0 0 8px transparent; }
}
.pulse {
    animation: pulse-accent 2s ease-in-out infinite;
}

/* ââ Responsive ââââââââââââââââââââââââââââââââââ */
@media (max-width: 768px) {
    .stat-value {
        font-size: 1.25rem;
    }
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
    }
}

/* ââ Theme Preview Swatches ââââââââââââââââââââââ */
.theme-swatch {
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}
.theme-swatch:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.theme-swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.theme-swatch-header {
    height: 30%;
    width: 100%;
}
.theme-swatch-body {
    height: 70%;
    width: 100%;
    padding: 6%;
    display: flex;
    gap: 6%;
}
.theme-swatch-sidebar {
    width: 25%;
    border-radius: 4px;
}
.theme-swatch-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8%;
}
.theme-swatch-line {
    height: 12%;
    border-radius: 2px;
    opacity: 0.4;
}
.theme-swatch-card {
    flex: 1;
    border-radius: 4px;
}
