/* --- New CSS Variables --- */
:root {
    --background: #f9f9f9; /* A clean, bright canvas */
    --primary: #6a11cb;   /* Deep creative purple */
    --secondary: #eb337a; /* Vibrant magenta */
    --accent1: #00f2fe;   /* Bright cyan/teal */
    --accent2: #f5a623;   /* Warm, energetic orange */
    --dark-text: #2c3e50;
    --light-text: #8a8a8a;
}

/* Google Font Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6; /* bg-gray-100 */
}

/* --- ADDED: Skip Link Styles (Issue #7) --- */
.skip-to-content {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background-color: #4F46E5; /* indigo-600 */
    color: white;
    padding: 1rem;
    z-index: 9999;
}
.skip-to-content:focus {
    position: fixed;
    top: 10px;
    left: 10px;
    width: auto;
    height: auto;
    overflow: visible;
    text-decoration: none;
    border-radius: 0.375rem; /* rounded-md */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); /* shadow-lg */
}


/* --- Keyframe Animations (Corrected Syntax) --- */
@keyframes toast-in {
    0% { transform: translateY(-100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100%); opacity: 0; }
}
@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes fade-in-up {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes tooltip-in {
    0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Animation Utility Classes (applied via className in JSX) --- */
.animate-toast-in { animation: toast-in 0.5s ease-out forwards; }
.animate-toast-out { animation: toast-out 0.5s ease-in forwards; }
.animate-fade-in { animation: fade-in 0.3s ease-out; }
.animate-fade-in-up { animation: fade-in-up 0.5s ease-out; }
.animate-scale-in { animation: scale-in 0.3s ease-out; }
.animate-tooltip-in { animation: tooltip-in 0.2s ease-out forwards; }


/* Styles for Onboarding Modal */
.onboarding-modal-backdrop {
    animation: fade-in 0.3s ease-out forwards;
}
.onboarding-modal-content {
    animation: scale-in 0.3s ease-out forwards;
}

/* Style for active Front/Back toggle in editor */
.editor-side-toggle-active {
    background-color: #4F46E5; /* indigo-600 */
    color: white;
    border-color: #4F46E5; /* indigo-600 */
    border-radius: 0.375rem; /* rounded-md */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

/* Style for template card previews */
.template-card {
    aspect-ratio: 1014 / 639; /* Standard ID card ratio */
    background-color: #f3f4f6; /* gray-100 */
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 0.375rem; /* rounded-md */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem; /* p-2 */
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden; /* Hide overflowing parts of the mini-preview */
}
.template-card:hover {
    border-color: #4F46E5; /* hover:border-indigo-600 */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); /* shadow-lg */
}
.template-card-name {
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: #4b5563; /* text-gray-600 */
    margin-top: 0.5rem; /* mt-2 */
}

/* Make vertical tabs in editor left panel take full height */
.editor-left-panel > div {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.editor-left-panel > div > .flex-grow {
    /* This class is applied by the Tabs component */
    height: 100%;
    overflow-y: auto;
}

/* Custom Animated Tooltip Style */
.custom-tooltip {
    position: fixed; /* Changed from absolute for better viewport positioning */
    background-color: #1f2937; /* gray-800 */
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    z-index: 10000;
    pointer-events: none; /* So it doesn't interfere with mouse events */
    white-space: nowrap;
    /* Animation */
    opacity: 0;
    /* transform is set inline by TooltipDisplay component */
    animation: tooltip-in 0.2s ease-out forwards;
}

/* Styles for grid panels in the editor sidebar */
.editor-grid-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem; /* Handles spacing between buttons */
}

.editor-grid-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* space-y: 1px; REMOVED - Use gap on parent or margin */
    padding: 0.5rem;
    background-color: white;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 0.375rem; /* rounded-md */
    color: #374151; /* text-gray-700 */
    font-size: 0.75rem; /* text-xs */
    line-height: 1rem;
    text-align: center;
    transition: all 0.2s;
}

.editor-grid-button:hover {
    background-color: #f9fafb; /* gray-50 */
    border-color: #4F46E5; /* indigo-600 */
    color: #4F46E5; /* indigo-600 */
}

/* --- ADDED: Ensure buttons are accessible (Issue #4, #7) --- */
.editor-grid-button {
    /* ... existing styles ... */
    min-height: 44px; /* Ensure minimum touch target size */
    min-width: 44px; /* Ensure minimum touch target size */
}


.editor-grid-button svg {
    width: 1.5rem; /* w-6 */
    height: 1.5rem; /* h-6 */
    margin-bottom: 0.25rem; /* Adds space below icon */
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
    width: fit-content;
    height: fit-content;
    margin: auto; /* Centers the wrapper block */
}
canvas {
   display: block; /* Removes extra space */
}

/* Editor Toolbar Button Styles (Standard CSS) */
.tool-button {
    background-color: white;
    color: #374151; /* gray-700 */
    padding: 0.5rem; /* p-2 */
    border: 1px solid #D1D5DB; /* border-gray-300 */
    border-radius: 0.25rem; /* rounded */
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px; /* ADDED: Ensure minimum touch target size */
    min-width: 44px; /* ADDED: Ensure minimum touch target size */
}
.tool-button:hover {
    background-color: #E5E7EB; /* gray-200 */
}
.tool-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.tool-button:disabled:hover {
    background-color: white;
}
.tool-button svg {
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
}

.tool-separator {
    width: 1px;
    height: 1.5rem; /* h-6 */
    background-color: #D1D5DB; /* bg-gray-300 */
    margin-left: 0.25rem; /* Add some space around separator */
    margin-right: 0.25rem;
}

/* Home Dashboard Card (Standard CSS) */
/* --- MODIFIED: Use `button` for accessibility (Issue #7) --- */
.dashboard-card {
    background-color: white;
    padding: 1.5rem; /* p-6 */
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); /* shadow-lg */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* transition-all duration-300 */
    border: 1px solid transparent; /* Add transparent border for hover effect */
    /* --- ADDED --- */
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.dashboard-card:hover {
     box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); /* hover:shadow-xl */
     transform: translateY(-0.25rem); /* hover:-translate-y-1 */
}

/* Easy Editor Styles (Standard CSS) */
.easy-editor-step {
    background-color: white;
    padding: 1.5rem; /* p-6 */
    border-radius: 0.5rem; /* rounded-lg */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); /* shadow-md */
    transition: all 0.3s ease-in-out; /* transition-all duration-300 */
}
.easy-editor-step-header {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
    color: #1f2937; /* text-gray-800 */
    margin-bottom: 1rem; /* mb-4 */
    padding-bottom: 0.5rem; /* pb-2 */
    border-bottom: 1px solid #e5e7eb; /* border-b border-gray-200 */
}
.easy-editor-frame-btn {
    width: 5rem; /* w-20 */
    height: 5rem; /* h-20 */
    border: 2px solid #d1d5db; /* border-2 border-gray-300 */
    border-radius: 0.375rem; /* rounded-md */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    min-height: 44px; /* ADDED: Ensure minimum touch target size */
    min-width: 44px; /* ADDED: Ensure minimum touch target size */
}
.easy-editor-frame-btn:hover {
    border-color: #6366f1; /* hover:border-indigo-500 */
     box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); /* hover:shadow-md */
}
.easy-editor-frame-btn.active {
    border-color: #4f46e5; /* active:border-indigo-600 */
    /* Tailwind ring uses box-shadow */
    box-shadow: 0 0 0 2px #a5b4fc; /* ring-2 ring-indigo-300 (adjusted color) */
}

/* Canvas container max dimensions */
.canvas-container {
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* --- New "Spark" Loader --- */
#global-loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: var(--background, #f9f9f9); /* Use var with fallback */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column; /* Added */
    gap: 40px; /* Added */
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.spark-container {
    position: relative;
    width: 150px;
    height: 150px;
}

/* The central "core" that the pieces fly into */
.spark-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    animation: pulseCore 2s ease-in-out infinite 1.2s;  
    will-change: transform, opacity; /* <-- ADDED FOR PERFORMANCE */
}

/* The creative "wisps" that fly in */
.wisp {
    position: absolute;
    width: 30px;
    height: 30px;
    /* This asymmetric radius creates the "wisp" or "blob" shape */
    border-radius: 50% 50% 10% 50%;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    
    /* Shared animation properties */
    animation-name: assemble;
    animation-duration: 1.2s;
    animation-timing-function: cubic-bezier(0.6, 0.01, 0.1, 1);
    animation-iteration-count: infinite;
    will-change: transform, opacity; /* <-- ADDED FOR PERFORMANCE */
}

.wisp-1 {
    background: linear-gradient(45deg, var(--primary), #a239ea);
    top: 0;
    left: 0;
    animation-delay: 0s;
}

.wisp-2 {
    background: linear-gradient(45deg, var(--secondary), #f867a0);
    top: 0;
    right: 0;
    animation-delay: 0.2s;
}

.wisp-3 {
    background: linear-gradient(45deg, var(--accent1), #75f8ff);
    bottom: 0;
    right: 0;
    animation-delay: 0.4s;
}

.wisp-4 {
    background: linear-gradient(45deg, var(--accent2), #fecb7e);
    bottom: 0;
    left: 0;
    animation-delay: 0.6s;
}

/* --- Loading Text --- */
.loading-text-container {
    text-align: center;
}

.title-main {
    font-size: 22px;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 4px;
}

.title-sub {
    font-size: 15px;
    color: var(--light-text);
    position: relative;
    display: inline-block;
    width: 220px;
    height: 20px; /* Prevents layout shift */
}
    
.loading-step {
    position: absolute;
    left: 0;
    right: 0;
    opacity: 0;
    animation: fadeText 4.8s linear infinite; /* 1.2s * 4 steps */
    will-change: transform, opacity; /* <-- ADDED FOR PERFORMANCE */
}

.loading-step:nth-child(1) { animation-delay: 0s; }
.loading-step:nth-child(2) { animation-delay: 1.2s; }
.loading-step:nth-child(3) { animation-delay: 2.4s; }
.loading-step:nth-child(4) { animation-delay: 3.6s; }


/* --- New Animations --- */

/* Keyframes for the components flying in */
@keyframes assemble {
    0% {
        transform: translate(0, 0) scale(0.5) rotate(0deg);
        opacity: 0;
        /* border-radius: 50% 50% 10% 50%; <-- REMOVED (base style is fine) */
    }
    15% {
        opacity: 1;
    }
    70% {
        /* Fly to center, rotate, and morph into a circle */
        transform: translate(calc(var(--tx, 0) * 1px), calc(var(--ty, 0) * 1px)) scale(1) rotate(360deg);
        opacity: 1;
        /* border-radius: 50%; <-- REMOVED (morphing is expensive) */
    }
    90%, 100% {
        /* Disappear into the core */
        transform: translate(calc(var(--tx, 0) * 1px), calc(var(--ty, 0) * 1px)) scale(0.2) rotate(360deg);
        opacity: 0;
    }
}

/* Keyframes for the central core pulsing */
@keyframes pulseCore {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8; /* <-- CHANGED */
        /* box-shadow: 0 4px 15px rgba(0,0,0,0.05); <-- REMOVED (expensive) */
    }
    50% {
        transform: scale(1.1);
        opacity: 1; /* <-- CHANGED */
        /* box-shadow: 0 6px 25px rgba(106, 17, 203, 0.2); <-- REMOVED (expensive) */
    }
}

/* Keyframes for the fading text */
@keyframes fadeText {
    0% { opacity: 0; transform: translateY(10px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* ---
--- NEW STYLES ADDED BELOW ---
--- */

/* --- New Homepage Dashboard Styles --- */
.home-background-gradient {
    position: absolute;
    top: -100px; /* Start higher up */
    left: 0;
    right: 0;
    height: 600px; /* Make it a bit taller */
    background: radial-gradient(ellipse at 50% -50%, rgba(99, 102, 241, 0.1), transparent 70%); /* Faint indigo-400 glow */
    z-index: 0;
    pointer-events: none;
    overflow: hidden; /* Ensure it doesn't spill */
}

/* Helper colors for HomeActionCard */
/* These mimic Tailwind's color palette for consistency */

/* Indigo */
.indigo-bg-light { background-color: #eef2ff; } /* indigo-50 */
.indigo-text { color: #4f46e5; } /* indigo-600 */
.indigo-hover-border:hover { border-color: #6366f1; } /* hover:border-indigo-500 */

/* Teal */
.teal-bg-light { background-color: #f0fdfa; } /* teal-50 */
.teal-text { color: #0d9488; } /* teal-600 */
.teal-hover-border:hover { border-color: #2dd4bf; } /* hover:border-teal-400 */

/* Purple */
.purple-bg-light { background-color: #faf5ff; } /* purple-50 */
.purple-text { color: #9333ea; } /* purple-600 */
.purple-hover-border:hover { border-color: #a855f7; } /* hover:border-purple-500 */

/* Sky */
.sky-bg-light { background-color: #f0f9ff; } /* sky-50 */
.sky-text { color: #0284c7; } /* sky-600 */
.sky-hover-border:hover { border-color: #38bdf8; } /* hover:border-sky-400 */

/* Green */
.green-bg-light { background-color: #f0fdf4; } /* green-50 */
.green-text { color: #16a34a; } /* green-600 */
.green-hover-border:hover { border-color: #4ade80; } /* hover:border-green-400 */

/* Amber */
.amber-bg-light { background-color: #fffbeb; } /* amber-50 */
.amber-text { color: #d97706; } /* amber-600 */
.amber-hover-border:hover { border-color: #fcd34d; } /* hover:border-amber-400 */

/* --- ADDED: Mobile Menu Styles (Issue #4) --- */
.mobile-nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40; /* Below the menu itself */
    animation: fade-in 0.3s ease-out;
}

.mobile-nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    background-color: white;
    z-index: 50;
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    /* Slide-in animation */
    transform: translateX(-100%);
    animation: slide-in 0.3s ease-out forwards;
}

@keyframes slide-in {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(0); }
}

@keyframes slide-out {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

.mobile-nav-menu.closing {
    animation: slide-out 0.3s ease-in forwards;
}

/* ---
--- NEW STYLES FOR REDESIGN ---
--- */

/* --- New Homepage Hero --- */
.home-hero-title {
    /* A subtle gradient for the "creative" feel */
    background: linear-gradient(120deg, var(--primary, #6a11cb), #3b0769);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

.home-hero-subtitle {
    font-size: 1.25rem; /* text-xl */
    color: #4b5563; /* text-gray-600 */
    max-width: 600px;
    margin: 1rem auto 2rem auto; /* mb-4 and mb-8 */
}

/* --- New Homepage Mode Selection Cards --- */
.mode-selection-card {
    display: flex;
    flex-direction: column;
    background-color: white;
    padding: 1.5rem; /* p-6 */
    border-radius: 0.75rem; /* rounded-xl */
    border: 1px solid #e5e7eb; /* border-gray-200 */
    cursor: pointer;
    transition: all 0.2s ease-out;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}
.mode-selection-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); /* shadow-xl */
    border-color: #a5b4fc; /* border-indigo-300 */
}
.mode-selection-card h3 {
    font-size: 1.5rem; /* text-2xl */
    font-weight: 700;
}
.mode-selection-card p {
    color: #6b7280; /* text-gray-500 */
    font-size: 0.875rem; /* text-sm */
    flex-grow: 1; /* Pushes the "Recommended" tag down */
    margin-bottom: 1rem;
}


/* --- New Admin Stat Cards --- */
.admin-stat-card {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 0.75rem; /* rounded-xl */
    padding: 1.5rem; /* p-6 */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05); /* shadow-md */
    border: 1px solid #e5e7eb; /* border-gray-200 */
    transition: all 0.2s ease-out;
}
.admin-stat-card:hover {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05); /* shadow-lg */
}
.admin-stat-icon-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 3.5rem; /* w-14 */
    height: 3.5rem; /* h-14 */
    margin-right: 1.5rem; /* mr-6 */
}
.admin-stat-icon-wrapper svg {
    width: 1.75rem; /* w-7 */
    height: 1.75rem; /* h-7 */
}
.admin-stat-content h3 {
    font-size: 0.875rem; /* text-sm */
    font-weight: 600; /* font-semibold */
    color: #6b7280; /* text-gray-500 */
    text-transform: uppercase;
}
.admin-stat-content p {
    font-size: 2.25rem; /* text-4xl */
    font-weight: 800; /* font-extrabold */
    color: #1f2937; /* text-gray-800 */
    line-height: 1;
}

/* --- New Admin Sidebar --- */
.admin-sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem; /* px-4 py-3 */
    margin: 0.25rem 0; /* space-y-1 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 600; /* font-semibold */
    border-radius: 0.5rem; /* rounded-lg */
    transition: all 0.2s ease-out;
    color: #4b5563; /* text-gray-600 */
}
.admin-sidebar-nav-link:hover {
    background-color: #f3f4f6; /* hover:bg-gray-100 */
    color: #1f2937; /* hover:text-gray-900 */
}
.admin-sidebar-nav-link.active {
    background-color: #eef2ff; /* bg-indigo-50 */
    color: #4f46e5; /* text-indigo-700 */
}
.admin-sidebar-nav-link svg {
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
    margin-right: 0.75rem; /* mr-3 */
}
/* ---
--- NEW STYLES FOR AUTH REDESIGN ---
--- */

.auth-decorator-gradient {
    /* A modern, creative gradient - NO PINK! */
    background: linear-gradient(160deg, #4f46e5 0%, #06b6d4 100%); /* Indigo to Cyan */
}

.auth-decorator-text {
    position: relative;
    z-index: 10;
}

.auth-decorator-text h3 {
    font-size: 2.5rem; /* 4xl */
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.auth-decorator-text p {
    font-size: 1.125rem; /* xl */
    color: rgba(255, 255, 255, 0.8);
}

/* Subtle dots pattern for the background */
.auth-decorator-gradient::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.5;
}