@import url('variables.css');

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

html, body {
    font-family: var(--font);
    color: var(--text-dark);
    background: var(--off-white);
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ===================== Icons ===================== */
.icon { flex-shrink: 0; vertical-align: middle; display: inline-block; }
.btn .icon, a .icon, button .icon { margin-right: 6px; }
.btn .icon:only-child, a .icon:only-child, button .icon:only-child { margin-right: 0; }
label .icon, .field-label .icon { margin-right: 5px; }

.container { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

/* ===================== Glass Morphism ===================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, var(--secondary-lighter), var(--secondary) 55%, #150a22 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.auth-body::before, .auth-body::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    opacity: 0.5;
}
.auth-body::before {
    width: 420px; height: 420px;
    background: radial-gradient(circle, rgba(255,214,10,0.18), transparent 70%);
    top: -120px; right: -100px;
}
.auth-body::after {
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(147,51,234,0.35), transparent 70%);
    bottom: -140px; left: -100px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 44px 40px;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: floatIn 0.5s ease;
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-badge {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px;
    box-shadow: 0 6px 20px rgba(255,214,10,0.35);
    color: var(--secondary);
}
.auth-badge .icon { width: 34px; height: 34px; }

.auth-title { font-size: 26px; font-weight: 700; color: var(--text-dark); letter-spacing: 0.2px; }
.auth-subtitle { color: var(--text-light); font-size: 14px; margin-top: 4px; margin-bottom: 28px; }

.form-group { text-align: left; margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 700;
    color: var(--text-medium); margin-bottom: 7px;
    text-transform: uppercase; letter-spacing: 0.3px;
}

/* Icon and input sit side-by-side as flex children of one pill-shaped box,
   instead of stacking the icon on top of the input with absolute positioning.
   This avoids browser-specific z-index/compositing quirks where native form
   control rendering can paint over an overlapping absolutely-positioned icon. */
.glass-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    border: 1px solid var(--gray);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    transition: var(--transition);
}
.glass-input-wrap .icon {
    color: var(--text-light);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.glass-input-wrap:hover { border-color: var(--text-light); }
.glass-input-wrap:focus-within { border-color: var(--text-medium); }
.glass-input-wrap:focus-within .icon { color: var(--text-medium); }

.glass-input, .glass-input-wrap input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 13px 0;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.3;
}
.glass-input-wrap input:focus { outline: none; box-shadow: none; }
.glass-input-wrap input::placeholder { color: var(--text-light); opacity: 0.8; }

.glass-input-wrap input[type="date"] { color-scheme: light; }
.glass-input-wrap input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
.glass-input-wrap input[type="number"] { -moz-appearance: textfield; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font);
    font-weight: 700;
    font-size: 16px;
    padding: 13px 22px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--secondary);
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 28px rgba(255,214,10,0.4); }
.btn-block { width: 100%; }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-accent { background: var(--accent); color: var(--white); }
.btn-outline { background: transparent; border: 1px solid var(--gray); color: var(--text-dark); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 7px 14px; font-size: 14px; }

.auth-back-link {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 22px; color: var(--accent); font-weight: 600; font-size: 14px;
}

.auth-error, .auth-success {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 14px; margin-bottom: 18px; text-align: left;
}
.auth-error {
    background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.25);
    color: #b91c1c;
}
.auth-success {
    background: rgba(22,163,74,0.08); border: 1px solid rgba(22,163,74,0.25);
    color: #15803d;
}
.auth-error .icon, .auth-success .icon { flex-shrink: 0; }

/* ===================== Admin Shell ===================== */
.admin-shell { display: flex; min-height: 100vh; background: var(--gray-light); }

.sidebar {
    width: 260px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--secondary), var(--secondary-light));
    color: var(--white);
    padding: 22px 0;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 22px 22px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-brand .badge-icon {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    color: var(--secondary); flex-shrink: 0;
}
.sidebar-brand .badge-icon .icon { width: 22px; height: 22px; }
.sidebar-brand-text { font-size: 17px; font-weight: 700; line-height: 1.2; }
.sidebar-brand-text small { display: block; font-weight: 400; font-size: 12px; opacity: 0.6; }

.sidebar-nav { list-style: none; padding: 14px 12px; }
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.75); font-weight: 500; font-size: 15px;
    transition: var(--transition);
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); text-decoration: none; }
.sidebar-nav a.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--secondary); font-weight: 700; }
.sidebar-nav .icon { width: 19px; height: 19px; flex-shrink: 0; }

.main-content { flex: 1; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 28px; background: var(--white); box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 22px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.topbar-user .avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: var(--white); display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.topbar-user-menu { position: relative; }
.topbar-dropdown {
    display: none; position: absolute; right: 0; top: 48px; min-width: 180px;
    background: var(--white); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: 8px; z-index: 20;
}
.topbar-dropdown.open { display: block; }
.topbar-dropdown a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 6px; color: var(--text-dark); font-size: 14px; }
.topbar-dropdown a:hover { background: var(--gray-light); text-decoration: none; }

.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--text-dark);
    display: inline-flex; align-items: center; justify-content: center; padding: 4px;
}

.page-body { padding: 26px 28px; }

/* ===================== Cards & Stat Grid ===================== */
.card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 22px; margin-bottom: 22px;
}
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px; margin-bottom: 24px;
}
.stat-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; position: relative; overflow: hidden;
    border-left: 4px solid var(--accent);
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.yellow { border-left-color: var(--primary); }
.stat-card.purple { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card-icon {
    width: 42px; height: 42px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px; background: rgba(147,51,234,0.08); color: var(--accent);
}
.stat-card-icon .icon { width: 22px; height: 22px; }
.stat-card.yellow .stat-card-icon { background: rgba(255,214,10,0.15); color: var(--primary-dark); }
.stat-card.purple .stat-card-icon { background: rgba(147,51,234,0.1); color: var(--accent); }
.stat-card.success .stat-card-icon { background: rgba(22,163,74,0.1); color: var(--success); }
.stat-card.warning .stat-card-icon { background: rgba(217,119,6,0.1); color: var(--warning); }
.stat-card.danger .stat-card-icon { background: rgba(220,38,38,0.1); color: var(--danger); }
.stat-card-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-card-label { font-size: 13px; color: var(--text-light); margin-top: 6px; font-weight: 500; }

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data-table th {
    text-align: left; padding: 12px 14px; background: var(--gray-light);
    font-weight: 700; color: var(--text-medium); font-size: 13px; text-transform: uppercase; letter-spacing: 0.3px;
    white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-light); }
table.data-table tr:hover td { background: rgba(147,51,234,0.03); }

.badge {
    display: inline-block; padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-success { background: rgba(22,163,74,0.12); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.12); color: var(--danger); }
.badge-info { background: rgba(37,99,235,0.12); color: var(--info); }
.badge-purple { background: rgba(147,51,234,0.12); color: var(--accent); }
.badge-gray { background: var(--gray-light); color: var(--text-light); }

/* ===================== Forms ===================== */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 220px; }
label.field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-medium); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
    width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--gray); font-family: var(--font); font-size: 15px;
    background: var(--white); color: var(--text-dark); transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(147,51,234,0.12);
}
.field-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* ===================== Alerts / Flash ===================== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-success { background: rgba(22,163,74,0.1); color: #15803d; border: 1px solid rgba(22,163,74,0.25); }
.alert-danger { background: rgba(220,38,38,0.1); color: #b91c1c; border: 1px solid rgba(220,38,38,0.25); }
.alert-info { background: rgba(37,99,235,0.1); color: #1d4ed8; border: 1px solid rgba(37,99,235,0.25); }
.alert-warning { background: rgba(217,119,6,0.1); color: #b45309; border: 1px solid rgba(217,119,6,0.25); }

/* ===================== Permission Matrix ===================== */
.perm-matrix { width: 100%; border-collapse: collapse; }
.perm-matrix th, .perm-matrix td { padding: 10px 12px; border-bottom: 1px solid var(--gray-light); text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; font-weight: 600; }
.perm-matrix th { background: var(--secondary); color: var(--white); font-size: 13px; }
.perm-matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* ===================== Buttons row / toolbar ===================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===================== Modal ===================== */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(36,18,56,0.55);
    z-index: 100; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: var(--radius); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--gray-light); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--gray-light); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }

/* Cursor glow effect */
.cursor-glow {
    position: fixed; top: 0; left: 0; width: 380px; height: 380px;
    border-radius: 50%; pointer-events: none; z-index: 0;
    background: radial-gradient(circle, rgba(147,51,234,0.10), transparent 70%);
    transform: translate(calc(var(--mx, 50vw) - 50%), calc(var(--my, 50vh) - 50%));
    transition: opacity 0.2s ease;
}

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left 0.25s ease; }
    .sidebar.open { left: 0; }
    .main-content { width: 100%; }
}
