/*
 * Magick Dictionary Premium Stylesheet
 * Dark Mystical Theme & Glassmorphism Design System
 * 
 * Responsive Optimization: Designed for Desktop, Tablet, and Mobile screens.
 */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

:root {
    --bg-dark: #0b0816;
    --bg-deep: #110d24;
    --glass-bg: rgba(20, 16, 41, 0.65);
    --glass-border: rgba(162, 120, 255, 0.15);
    --glass-border-focus: rgba(212, 175, 55, 0.4);
    
    /* Harmonious Accents */
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --gold-hover: #ffdf7a;
    --purple-glow: rgba(162, 120, 255, 0.25);
    --magenta: #d946ef;
    
    /* Text Colors */
    --text-primary: #f3f1f6;
    --text-muted: #a69fb7;
    --text-dark: #1f1b2e;
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(162, 120, 255, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(31, 23, 64, 0.6) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(93, 27, 107, 0.3) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(13, 10, 27, 1) 0%, rgba(7, 5, 15, 1) 100%);
    background-attachment: fixed;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 0;
    color: var(--text-primary);
}

h1 {
    font-size: 2.5rem;
    text-shadow: 0 0 15px var(--purple-glow), 0 0 2px var(--gold);
    background: linear-gradient(135deg, #ffffff 30%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

p {
    color: var(--text-muted);
}

a {
    color: var(--gold);
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    color: var(--gold-hover);
    text-shadow: 0 0 8px var(--gold-glow);
}

/* Glassmorphic Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    box-sizing: border-box;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.4),
        inset 0 0 20px 0 rgba(255, 255, 255, 0.02);
    transition: var(--transition-smooth);
    box-sizing: border-box;
}

.glass-panel:hover {
    border-color: rgba(162, 120, 255, 0.25);
    box-shadow: 
        0 12px 40px 0 rgba(0, 0, 0, 0.5),
        0 0 30px 0 var(--purple-glow);
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--gold);
    filter: drop-shadow(0 0 8px var(--gold-glow));
    animation: pulse-glow 3s infinite alternate;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons and Inputs */
.btn {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 1px;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(162, 120, 255, 0.2) 100%);
    box-shadow: 0 0 10px rgba(162, 120, 255, 0.1);
}

.btn:hover {
    background: var(--gold);
    color: var(--text-dark);
    box-shadow: 
        0 0 15px var(--gold-glow),
        0 0 5px var(--gold);
    transform: translateY(-2px);
}

.btn-danger {
    border-color: #ef4444;
    color: #ef4444;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--gold);
}

.form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1rem;
    background: rgba(10, 8, 20, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    transition: var(--transition-smooth);
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--glass-border-focus);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

/* Authentication Page Card */
.auth-card {
    max-width: 480px;
    margin: 4rem auto;
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-footer {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Access Key Alert Display */
.key-reveal {
    background: rgba(162, 120, 255, 0.1);
    border: 1px dashed var(--gold);
    padding: 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    text-align: center;
    box-sizing: border-box;
    word-break: break-all;
}

.key-code {
    font-family: 'Fira Code', monospace;
    font-size: 1.25rem;
    color: var(--gold-hover);
    letter-spacing: 1px;
    font-weight: 600;
    margin: 0.5rem 0;
    user-select: all;
    display: block;
    word-break: break-all;
}

/* Dashboard UI Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 380px 1fr;
    }
}

/* Info Badges & User Status Details */
.user-info-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--gold);
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-basic {
    background: rgba(166, 159, 183, 0.2);
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

.badge-pro {
    background: rgba(162, 120, 255, 0.2);
    color: #c77dff;
    border: 1px solid #c77dff;
}

.badge-master {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold);
    border: 1px solid var(--gold);
}

.badge-admin {
    background: rgba(217, 70, 239, 0.2);
    color: var(--magenta);
    border: 1px solid var(--magenta);
}

/* Upload Component Styles */
.upload-zone {
    border: 2px dashed rgba(162, 120, 255, 0.3);
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.04);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.05);
}

.upload-icon {
    font-size: 3.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    transition: var(--transition-smooth);
}

.upload-zone:hover .upload-icon {
    color: var(--gold);
    transform: scale(1.1);
}

#image-preview-container {
    margin-top: 1.5rem;
    display: none;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    max-height: 300px;
    border: 1px solid var(--glass-border);
}

#image-preview {
    width: 100%;
    height: auto;
    object-fit: contain;
    max-height: 300px;
    display: block;
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(11, 8, 22, 0.85);
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.remove-btn:hover {
    background: #ef4444;
    color: white;
}

/* Shimmer Loading Component */
.analysis-loader {
    display: none;
    text-align: center;
    padding: 3rem 0;
}

.mystical-ring {
    width: 80px;
    height: 80px;
    border: 2px solid rgba(162, 120, 255, 0.1);
    border-top: 2px solid var(--gold);
    border-bottom: 2px solid var(--magenta);
    border-radius: 50%;
    margin: 0 auto 1.5rem auto;
    animation: rotate 2.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    filter: drop-shadow(0 0 10px rgba(162, 120, 255, 0.4));
    position: relative;
}

.mystical-ring::after {
    content: "✦";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: var(--gold);
    animation: pulse-glow 1.5s infinite alternate;
}

.loading-text {
    font-family: 'Cinzel', serif;
    color: var(--gold-hover);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.shimmer-bar {
    height: 4px;
    width: 150px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.shimmer-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    animation: shimmer 1.5s infinite;
}

/* Markdown Esoteric Result Rendering */
.result-panel {
    display: none;
}

.markdown-body {
    color: var(--text-primary);
    font-size: 1.02rem;
    line-height: 1.7;
    word-wrap: break-word;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    color: var(--gold);
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body blockquote {
    border-left: 4px solid var(--gold);
    background: rgba(212, 175, 55, 0.05);
    padding: 1rem 1.25rem;
    border-radius: 0 8px 8px 0;
    margin: 1.5rem 0;
}

.markdown-body blockquote p {
    color: var(--text-primary);
    font-style: italic;
    margin: 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    display: block;
    overflow-x: auto;
}

.markdown-body th, .markdown-body td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    min-width: 120px;
}

.markdown-body th {
    background: rgba(162, 120, 255, 0.1);
    color: var(--gold);
    font-family: 'Cinzel', serif;
}

.markdown-body code {
    font-family: 'Fira Code', monospace;
    background: rgba(162, 120, 255, 0.15);
    color: #ff79c6;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    word-break: break-all;
}

.markdown-body pre {
    background: rgba(10, 8, 20, 0.85);
    border: 1px solid var(--glass-border);
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Admin Dashboard Table */
.admin-table-container {
    overflow-x: auto;
    margin-top: 2rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th, .admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

.admin-table th {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    background: rgba(255, 255, 255, 0.02);
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.action-btn {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 5, 15, 0.8);
    z-index: 1000;
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-content {
    background: var(--bg-deep);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 0 30px rgba(162, 120, 255, 0.2);
    position: relative;
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-modal:hover {
    color: #ef4444;
}

/* Alerts and Notifications */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

/* Animations */
@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse-glow {
    0% {
        opacity: 0.7;
        text-shadow: 0 0 5px rgba(212, 175, 55, 0.2);
    }
    100% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
    }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ==========================================================================
   Responsive Media Queries (Mobile & Tablet Optimization)
   ========================================================================== */

@media (max-width: 768px) {
    /* Fluid Container spacing */
    .container {
        padding: 1rem 0.75rem !important;
    }

    /* Shrink excessive card padding */
    .glass-panel {
        padding: 1.25rem !important;
        border-radius: 12px;
    }

    /* Responsive Typography */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.15rem;
    }

    /* Stack Header elements */
    header {
        flex-direction: column;
        gap: 1.25rem;
        text-align: center;
        padding: 1.25rem 1rem !important;
        margin-bottom: 1.5rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    /* Auth card margin compression */
    .auth-card {
        margin: 1.5rem auto;
    }

    /* Upload block scaling */
    .upload-zone {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 2.8rem;
        margin-bottom: 0.75rem;
    }

    /* Code block spacing adjustments */
    .markdown-body pre {
        padding: 0.75rem;
    }

    /* Modal spacing compression */
    .modal-content {
        padding: 1.5rem 1.25rem;
    }
}

@media (max-width: 480px) {
    /* Narrow screens font adjustments */
    h1 {
        font-size: 1.6rem;
    }
    
    .key-code {
        font-size: 1.05rem;
        letter-spacing: 0px;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    
    .info-item > span:last-child {
        align-self: flex-end;
    }

    /* Smaller buttons on mobile */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Full-Screen Vertically Centered Auth Portal Layout
   ========================================================================== */

.auth-page-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem !important;
    box-sizing: border-box;
    overflow-y: auto;
}

.auth-page-body .container {
    padding: 0 !important;
    margin: 0 auto !important;
    width: 100%;
    max-width: 480px;
}

.auth-page-body .auth-card {
    margin: 0 auto !important; /* Eliminates the massive top margin */
    padding: 1.75rem 1.5rem !important; /* Squeezes padding for compact balance */
    border-radius: 16px;
    box-shadow: 
        0 15px 35px 0 rgba(0, 0, 0, 0.5),
        0 0 35px 0 var(--purple-glow);
}

.auth-page-body .auth-header {
    margin-bottom: 1.25rem !important;
}

.auth-page-body .auth-header .logo-icon {
    font-size: 1.8rem !important;
}

.auth-page-body .auth-header h1 {
    font-size: 1.8rem !important;
    margin-top: 0.5rem !important;
}

.auth-page-body .auth-header p {
    font-size: 0.85rem !important;
    margin-top: 0.25rem !important;
}

.auth-page-body .form-group {
    margin-bottom: 1rem !important;
}

.auth-page-body .btn-primary {
    margin-top: 0.75rem !important;
}

