/* KKR Portal — Responsive styles */

:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --header-bg: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    --font: 'Sarabun', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Header */
.site-header {
    background: var(--header-bg);
    color: #fff;
    padding: 1.25rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    backdrop-filter: blur(4px);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

.brand p {
    font-size: 0.875rem;
    opacity: 0.85;
}

.btn-admin {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition);
    border: 1px solid rgba(255,255,255,0.2);
}

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

/* Main */
.main-content {
    flex: 1;
    padding: 2rem 1.25rem 3rem;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.hero p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto;
}

/* Department sections */
.dept-section {
    margin-bottom: 2.5rem;
}

.dept-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--dept-color, #1e40af);
}

.dept-icon-wrap {
    width: 40px;
    height: 40px;
    background: var(--dept-color, #1e40af);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.dept-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.empty-dept {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    color: var(--text-muted);
}

.empty-dept i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Site cards grid */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.site-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}

.site-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.site-card-icon {
    margin-bottom: 1rem;
}

.site-card-icon img,
.site-icon-img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
}

.site-icon-fa {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.site-icon-fa-sm {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.1rem;
}

.site-card-body {
    flex: 1;
    margin-bottom: 1.25rem;
}

.site-card-body h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.site-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--btn-color, #1e40af);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background var(--transition), transform var(--transition);
}

.site-card-btn:hover {
    background: var(--btn-hover, #1e3a8a);
}

.site-card-btn i { font-size: 0.8rem; opacity: 0.9; }

/* Footer */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.25rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.site-footer p + p {
    margin-top: 0.35rem;
}

.footer-credit {
    color: #1e3a8a;
    font-weight: 500;
}

.footer-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.55rem 0.85rem;
    margin-top: 0.85rem;
    padding: 0.45rem 1rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 0.85rem;
}

.footer-counter i {
    color: #2563eb;
    margin-right: 0.3rem;
}

.footer-counter strong {
    color: #1e3a8a;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.footer-counter-sep {
    width: 1px;
    height: 1em;
    background: #cbd5e1;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* ========== ADMIN STYLES ========== */

.admin-body {
    background: #f1f5f9;
}

.admin-nav {
    background: #1e293b;
    color: #fff;
    padding: 0.75rem 0;
}

.admin-nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-nav-brand {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    text-decoration: none;
}

.admin-nav-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.admin-nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background var(--transition), color var(--transition);
}

.admin-nav-links a:hover,
.admin-nav-links a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.admin-main {
    padding: 2rem 0 3rem;
}

.admin-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

select.form-control { cursor: pointer; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }

.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    background: #f8fafc;
    font-weight: 600;
    white-space: nowrap;
}

table.data-table tr:hover td { background: #f8fafc; }

.table-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    vertical-align: middle;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.color-preview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--header-bg);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 1.35rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-card .brand-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Icon preview in admin */
.icon-preview-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

.icon-preview-box img,
.icon-preview-box .site-icon-fa {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.35rem;
}

.btn-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: #2563eb;
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .brand h1 { font-size: 1.05rem; }
    .btn-admin span { display: none; }
    .hero h2 { font-size: 1.4rem; }
    .sites-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .admin-nav-links { width: 100%; }
}

@media (max-width: 480px) {
    .main-content { padding: 1.25rem 1rem 2rem; }
    .site-card { padding: 1.25rem; }
    .dept-header h3 { font-size: 1.1rem; }
}

/* Tablet / iPad */
@media (min-width: 769px) and (max-width: 1024px) {
    .sites-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .sites-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
