@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
    :root {
        --admin-bg: #f8fafc;
        --admin-surface: #ffffff;
        --admin-border: #e2e8f0;
        --admin-text: #0f172a;
        --admin-muted: #64748b;
        --admin-primary: #6366f1;
        --admin-secondary: #8b5cf6;
        --admin-info: #3b82f6;
        --admin-accent: #f59e0b;
        --admin-success: #10b981;
        --admin-danger: #ef4444;
        --admin-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
        --admin-radius: 14px;
        --admin-sidebar: #0f172a;
        --admin-sidebar-accent: #1e293b;
        --admin-sidebar-text: #e2e8f0;
        --admin-sidebar-muted: #94a3b8;
        --admin-font-body: "Manrope", "Segoe UI", sans-serif;
        --admin-font-heading: "Sora", "Segoe UI", sans-serif;
        --user-bg: #f8fafc;
        --user-surface: #ffffff;
        --user-text: #0f172a;
        --user-muted: #64748b;
        --user-primary: #2563eb;
        --user-accent: #0ea5e9;
        --user-border: #e2e8f0;
        --user-radius: 16px;
        --user-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
        --franchise-primary: #16a34a;
        --franchise-accent: #14b8a6;
    }

    body {
        font-family: var(--admin-font-body);
    }

    h1, h2, h3, h4, h5, h6 {
        font-family: var(--admin-font-heading);
    }
}

@layer base {
    .theme-admin {
        background: var(--admin-bg);
        color: var(--admin-text);
    }

    .theme-admin.dark {
        --admin-bg: #020617;
        --admin-surface: #0f172a;
        --admin-border: #1e293b;
        --admin-text: #e2e8f0;
        --admin-muted: #94a3b8;
        --admin-primary: #60a5fa;
        --admin-secondary: #38bdf8;
        --admin-info: #60a5fa;
        --admin-accent: #f59e0b;
        --admin-success: #22c55e;
        --admin-danger: #f87171;
        --admin-shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
        --admin-sidebar: #020617;
        --admin-sidebar-accent: #0f172a;
        --admin-sidebar-text: #e2e8f0;
        --admin-sidebar-muted: #94a3b8;
    }

    .theme-user {
        background: var(--user-bg);
        color: var(--user-text);
    }

    .theme-user.dark {
        --user-bg: #0f172a;
        --user-surface: #111827;
        --user-text: #e2e8f0;
        --user-muted: #94a3b8;
        --user-border: #1f2937;
        --user-primary: #38bdf8;
        --user-accent: #22d3ee;
        --user-shadow: 0 16px 30px rgba(15, 23, 42, 0.6);
    }

    .theme-franchise {
        background: var(--user-bg);
        color: var(--user-text);
        --user-primary: var(--franchise-primary);
        --user-accent: var(--franchise-accent);
    }

    .theme-franchise.dark {
        --user-bg: #0f172a;
        --user-surface: #111827;
        --user-text: #e2e8f0;
        --user-muted: #94a3b8;
        --user-border: #1f2937;
        --user-shadow: 0 16px 30px rgba(15, 23, 42, 0.6);
    }
}

@layer components {
    .admin-card {
        border-radius: var(--admin-radius);
        border: 1px solid var(--admin-border);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
        box-shadow: var(--admin-shadow);
        transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
        animation: card-fade-up .35s ease both;
    }

    .theme-admin.dark .admin-card {
        background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.92));
        border-color: #1e293b;
    }

    .admin-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 22px 36px rgba(15, 23, 42, 0.12);
        border-color: #bfdbfe;
    }

    .theme-admin.dark .admin-card:hover {
        border-color: #334155;
        box-shadow: 0 22px 36px rgba(2, 6, 23, 0.6);
    }

    .admin-badge {
        border-radius: 999px;
        font-size: 12px;
        padding: 4px 10px;
        font-weight: 600;
    }

    .admin-badge.success {
        background: #dcfce7;
        color: #166534;
    }

    .admin-badge.warning {
        background: #fef3c7;
        color: #92400e;
    }

    .admin-badge.danger {
        background: #fee2e2;
        color: #991b1b;
    }

    .user-card {
        border-radius: var(--user-radius);
        border: 1px solid var(--user-border);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
        box-shadow: var(--user-shadow);
        transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
        animation: card-fade-up .35s ease both;
    }

    .theme-user.dark .user-card {
        background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.94));
    }

    .theme-franchise.dark .user-card {
        background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.94));
    }

    .user-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 22px 36px rgba(15, 23, 42, 0.12);
        border-color: #bae6fd;
    }

    .user-badge {
        border-radius: 999px;
        font-size: 12px;
        padding: 4px 10px;
        font-weight: 600;
    }

    .user-badge.success {
        background: #dcfce7;
        color: #166534;
    }

    .user-badge.danger {
        background: #fee2e2;
        color: #991b1b;
    }

    .user-badge.warning {
        background: #fef3c7;
        color: #92400e;
    }
}

@keyframes card-fade-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@layer components {
    .panel-hero {
        position: relative;
        overflow: hidden;
        border-radius: 20px;
        border: 1px solid transparent;
        padding: 1.2rem 1.25rem;
        color: #fff;
        box-shadow: 0 22px 45px rgba(15, 23, 42, 0.18);
    }

    .panel-hero::before {
        content: "";
        position: absolute;
        inset: -40% -30%;
        background: radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.2), transparent 45%),
            radial-gradient(circle at 90% 70%, rgba(255, 255, 255, 0.25), transparent 42%);
        animation: hero-float 9s ease-in-out infinite;
    }

    .panel-hero > * {
        position: relative;
        z-index: 1;
    }

    .panel-hero-admin {
        background: linear-gradient(120deg, #0f172a, #2563eb 45%, #06b6d4);
    }

    .panel-hero-user {
        background: linear-gradient(120deg, #0b4f9c, #2563eb 45%, #0ea5e9);
    }

    .panel-hero-franchise {
        background: linear-gradient(120deg, #166534, #16a34a 45%, #0ea5a3);
    }

    .kpi-grid > .admin-card,
    .user-kpi-grid > .user-card,
    .franchise-kpi-grid > .user-card {
        position: relative;
        overflow: hidden;
    }

    .kpi-grid > .admin-card::before,
    .user-kpi-grid > .user-card::before,
    .franchise-kpi-grid > .user-card::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        height: 3px;
    }

    .kpi-grid > .admin-card:nth-child(4n + 1)::before,
    .user-kpi-grid > .user-card:nth-child(4n + 1)::before,
    .franchise-kpi-grid > .user-card:nth-child(4n + 1)::before {
        background: linear-gradient(90deg, #2563eb, #38bdf8);
    }

    .kpi-grid > .admin-card:nth-child(4n + 2)::before,
    .user-kpi-grid > .user-card:nth-child(4n + 2)::before,
    .franchise-kpi-grid > .user-card:nth-child(4n + 2)::before {
        background: linear-gradient(90deg, #16a34a, #22c55e);
    }

    .kpi-grid > .admin-card:nth-child(4n + 3)::before,
    .user-kpi-grid > .user-card:nth-child(4n + 3)::before,
    .franchise-kpi-grid > .user-card:nth-child(4n + 3)::before {
        background: linear-gradient(90deg, #d97706, #f59e0b);
    }

    .kpi-grid > .admin-card:nth-child(4n + 4)::before,
    .user-kpi-grid > .user-card:nth-child(4n + 4)::before,
    .franchise-kpi-grid > .user-card:nth-child(4n + 4)::before {
        background: linear-gradient(90deg, #db2777, #8b5cf6);
    }

    .announcement-overlay {
        position: fixed;
        inset: 0;
        z-index: 80;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
        background: rgba(2, 6, 23, 0.68);
        backdrop-filter: blur(2px);
    }

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

    .announcement-card {
        width: min(92vw, 500px);
        border-radius: 16px;
        border: 1px solid #cbd5e1;
        background: #fff;
        box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
        transform: translateY(12px) scale(0.98);
        opacity: 0;
        transition: transform 0.22s ease, opacity 0.22s ease;
        position: relative;
    }

    .announcement-card.show {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    .theme-user.dark .announcement-card,
    .theme-franchise.dark .announcement-card,
    .theme-admin.dark .announcement-card {
        background: #0f172a;
        border-color: #334155;
        color: #e2e8f0;
    }

    .announcement-content {
        padding: 16px;
    }

    .announcement-title {
        font-size: 1.1rem;
        font-weight: 700;
        line-height: 1.3;
    }

    .announcement-text {
        margin-top: 0.5rem;
        font-size: 0.92rem;
        line-height: 1.45;
        color: #475569;
    }

    .theme-user.dark .announcement-text,
    .theme-franchise.dark .announcement-text,
    .theme-admin.dark .announcement-text {
        color: #94a3b8;
    }

    .announcement-media {
        margin-top: 0.8rem;
        width: 100%;
        max-height: 260px;
        border-radius: 12px;
        object-fit: cover;
        border: 1px solid #cbd5e1;
    }

    .announcement-video {
        background: #000;
    }

    .announcement-link {
        margin-top: 0.8rem;
        display: inline-block;
        border-radius: 10px;
        background: #0f172a;
        color: #fff;
        padding: 8px 12px;
        font-size: 0.82rem;
        text-decoration: none;
    }

    .announcement-actions {
        margin-top: 0.9rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .announcement-remember {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 0.75rem;
        color: #64748b;
    }

    .announcement-btn {
        border-radius: 10px;
        border: 1px solid #cbd5e1;
        padding: 7px 12px;
        font-size: 0.8rem;
        font-weight: 600;
        color: #0f172a;
        background: #fff;
    }

    .announcement-close {
        position: absolute;
        right: 10px;
        top: 8px;
        border: 0;
        background: transparent;
        color: #64748b;
        font-size: 16px;
        line-height: 1;
        padding: 4px;
        cursor: pointer;
    }
}

@keyframes hero-float {
    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -10px, 0);
    }
}
