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

html, body {
    width: 100%;
    overflow-x: auto; /* allow horizontal scroll if any element still overflows to avoid clipping */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #333;
}

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

header {
    text-align: center;
    padding: 25px 20px;
    color: white;
    position: relative;
}

header h1 {
    font-size: 1.6rem;
    font-size: clamp(1.6rem, 2vw + 1.4rem, 3em);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    display: inline-flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap; /* prevent overflow on very narrow screens */
}

header .subtitle {
    font-size: 1.3em;
    opacity: 0.9;
    word-break: break-word; /* prevent character clipping on narrow screens */
    overflow-wrap: break-word;
}

header .logo img {
    width: 54px;
    height: 54px;
}

header .version {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 5px 15px;
    border-radius: 20px;
    margin-top: 15px;
    font-size: 0.9em;
}

.seasonal-theme-announcement {
    display: inline-block;
    background: rgba(255, 255, 255, 0.8);
    color: #c0392b;
    padding: 8px 20px;
    border-radius: 20px;
    margin-top: 15px;
    font-size: 1em;
    font-weight: 600;
    border: 2px solid #e74c3c;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.command-box {
    background: #f8fafc;
    color: #1e293b;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    position: relative;
    font-family: 'Consolas', 'Monaco', monospace;
    border: 1px solid #e2e8f0;
}

.command-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.command-box-title {
    /* Light mode color, overridden in dark mode */
    color: #475569;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s;
}

.copy-btn:hover {
    background: #5568d3;
}

.copy-btn:active {
    background: #4451b8;
}

.copy-btn-inline {
    padding: 3px 6px;
    margin-left: 4px;
    vertical-align: middle;
    font-size: 0.8em;
}

/* Script Button with Premium Badge */
.script-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    overflow: hidden;
}

.script-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    z-index: 0;
    border-radius: 8px;
}

.script-btn > * {
    position: relative;
    z-index: 1;
}

.script-btn:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
}

.script-btn.locked {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.85;
}

.script-btn.locked::before {
    background: linear-gradient(90deg, #718096 0%, #4a5568 100%);
}

.script-btn.locked:hover {
    transform: none;
    box-shadow: none;
}

.script-btn .script-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-btn .premium-badge {
    font-size: 1.1em;
    color: #f59e0b;
    flex-shrink: 0;
    line-height: 1;
}

.script-btn .admin-badge {
    font-size: 1.1em;
    color: #60a5fa;
    flex-shrink: 0;
    line-height: 1;
}

.script-btn .lock-icon {
    color: #a0aec0;
    font-size: 0.9em;
    flex-shrink: 0;
}

.script-btn.locked .premium-badge {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: #e2e8f0;
}

.command-text {
    background: #e2e8f0;
    padding: 12px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 0.95em;
    line-height: 1.6;
    overflow-wrap: break-word; /* break long tokens to avoid overflow */
}

.action-button {
    display: block;
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    text-align: center;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.action-button:active {
    transform: translateY(0);
}

.comparison {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-x: auto; /* allow horizontal scroll on small screens */
}

.comparison h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

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

.comparison-table th,
.comparison-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.comparison-table th {
    background: #f8f9fa;
    color: #667eea;
    font-weight: bold;
}

.comparison-table tr:hover {
    background: #f8f9fa;
}

.check-yes {
    color: #10b981;
    font-weight: bold;
}

.check-no {
    color: #ef4444;
}

footer {
    background: rgba(0,0,0,0.2);
    color: white;
    text-align: center;
    padding: 20px;
    /* Use auto margin to push footer to the bottom of the flex container (body) */
    margin-top: auto;
}

footer a {
    color: white;
    text-decoration: none;
    border-bottom: 1px solid white;
}

/* Custom scrollbar for script buttons container */
#script-buttons::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, Opera */
}

/* Search input styling */
#script-search:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.quick-start-tip {
    margin-top: clamp(10px, 2vw, 15px);
    padding-top: clamp(10px, 2vw, 15px);
    border-top: 1px solid #e5e7eb;
    font-size: 0.8em;
    font-size: clamp(0.8em, 2.2vw, 0.9em);
    color: #444;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

@media (max-width: 768px) {
    .method-card {
        padding: 25px;
    }

    #script-buttons {
        grid-template-columns: 1fr !important;
        max-height: 300px !important;
    }

    #script-search {
        width: 100% !important;
        margin-top: 8px;
    }
}

/* Additional responsive refinements */
@media (max-width: 1024px) {
    header h1 { font-size: 2.4em; }
}

@media (max-width: 640px) {
    header h1 { font-size: 1.8em; }
    .method-icon { font-size: 2.2em; }
    .method-card { padding: 20px; }
    .command-box { padding: 14px; }
    .command-text { 
        white-space: pre-wrap; 
        word-break: break-word; 
        font-size: 0.9em;
    }
    .action-button { font-size: 1em; padding: 12px 20px; }
}

/* Compact layout for very small phones */
@media (max-width: 480px) {
    .container { padding: 12px; }
    header { padding: 18px 12px; }
    header h1 { font-size: 1.5em; gap: 8px; }
    header .version { font-size: 0.75em; padding: 3px 10px; }
    .guide-columns { gap: 16px; grid-template-columns: minmax(0, 1fr); }
    .method-card { padding: 16px; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.18); }
    .method-icon { font-size: 1.8em; margin-right: 10px; }
    .method-title h2 { font-size: 1.4em; }
    .features { padding: 12px; }
    .features li { padding: 6px 0 6px 22px; }
    .warning-box { padding: 12px; font-size: 0.95em; }
    .command-box { padding: 12px; }
    .command-box-header { flex-wrap: wrap; gap: 8px; }
    .copy-btn { padding: 6px 10px; font-size: 0.8em; }
    .command-text { white-space: normal; word-break: break-word; font-size: 0.88em; }
    #script-select { font-size: 0.95em; padding: 10px; }
    .action-button { width: 100%; font-size: 0.98em; padding: 12px; }
}

/* Ultra-compact layout for very narrow screens (e.g., side panels, <360px) */
@media (max-width: 360px) {
    .container { padding: 10px; }
    header { padding: 14px 10px; }
    header h1 { font-size: 1.3em; }
    .guide-columns { gap: 12px; }
    .method-card { padding: 14px; }
    .method-title h2 { font-size: 1.2em; }
    .method-icon { font-size: 1.6em; margin-right: 8px; }
    .command-box { padding: 10px; }
    .command-text { font-size: 0.85em; white-space: normal; word-break: break-word; }
    #script-select { font-size: 0.9em; padding: 8px; }
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #10b981;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

.warning-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}

.warning-box strong {
    color: #d97706;
}

/* --- Component & Utility Styles (Refactored from inline) --- */

/* Utility Color Classes */
.text-success { color: #10b981; }
.text-warning { color: #f59e0b; }
.text-info { color: #3b82f6; }
.text-danger { color: #ef4444; }
.text-primary { color: #667eea; }

/* Script Runner Components */
.command-box-header-search {
    flex-wrap: wrap;
    gap: 10px;
}

#script-search {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1e293b;
    font-size: 0.9em;
    width: 200px;
    max-width: 100%;
    flex-shrink: 0;
}

#script-buttons {
    background: transparent;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: none; /* For Firefox */
    -ms-overflow-style: none;  /* For IE and Edge */
}

#script-buttons + div {
    margin-top: 8px;
    font-size: 0.85em;
    color: #64748b;
    text-align: center;
}

#script-select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    background: #fff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

/* --- New Unified Guide Section Styles --- */
.guide-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.guide-section h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2em;
}

.guide-intro {
    text-align: center;
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1em;
}

.guide-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

.guide-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border-top: 4px solid;
    display: flex;
    flex-direction: column;
}

.guide-card:nth-child(1) { border-top-color: #667eea; } /* PowerShell */
.guide-card:nth-child(2) { border-top-color: #10b981; } /* .bat File */

.guide-title {
    font-size: 1.3em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.guide-card:nth-child(1) .guide-title { color: #667eea; }
.guide-card:nth-child(2) .guide-title { color: #10b981; }

.guide-subtitle {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    background: #4a5568;
    color: white;
}

.guide-card:nth-child(1) .guide-subtitle { background: #667eea; }
.guide-card:nth-child(2) .guide-subtitle { background: #10b981; }

.guide-description {
    color: #555;
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 15px;
}

.guide-steps {
    padding-left: 20px;
    margin-bottom: 20px;
    color: #333;
}

.guide-steps li {
    margin-bottom: 8px;
}

.guide-tip {
    margin-top: auto; /* Pushes tip to the bottom of the card */
    padding: 12px;
    background: #e9ecef;
    border-radius: 8px;
    font-size: 0.9em;
    color: #495057;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.guide-tip i {
    margin-top: 3px;
    flex-shrink: 0;
}

.small-tip-box {
    margin-top: 8px !important;
    padding: 10px !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.small-tip-box .command-box-header {
    margin-bottom: 0;
}

.small-tip-box .copy-btn {
    padding: 4px 8px;
    font-size: 0.8em;
}

#exec-policy-tip {
    background: transparent;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    font-size: 0.7em;
    font-size: clamp(0.7em, 2vw, 0.85em);
    padding: 0;
    margin: 0;
    text-align: left;
    color: #495057;
}

#copy-exec-policy-btn {
    padding: 4px 8px;
    font-size: 0.7em;
    font-size: clamp(0.7em, 2vw, 0.8em);
    flex-shrink: 0;
}

.btn-download-bat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    text-align: center;
}
/* Footer */
footer .fa-heart {
    color: #e25555;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    background: #2d3748;
    border-left-color: #f59e0b;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: #e2e8f0;
}

/* Dark Mode - Command Box and children */
body.dark-mode .command-box {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode .command-box-title {
    color: #94a3b8;
}

body.dark-mode .command-text {
    background: #0f172a;
}

body.dark-mode #script-search {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode #script-select {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode #script-buttons + div {
    color: #94a3b8;
}

/* Dark Mode - Dropdown Header */
body.dark-mode .dropdown-header {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    border-bottom: 1px solid #4a5568;
}

/* Dark Mode - Script Buttons */
body.dark-mode .script-btn {
    background-color: #334155;
    border: 1px solid #4a5568;
    color: #e2e8f0;
}

body.dark-mode .script-btn::before {
    opacity: 0; /* Hide default gradient */
}

body.dark-mode .script-btn:hover {
    background-color: #4a5568;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

body.dark-mode .features h3 {
    color: #e2e8f0;
}

body.dark-mode .features li {
    color: #cbd5e0;
}

body.dark-mode .comparison-table th {
    background: #1a202c;
    color: #667eea;
}

body.dark-mode .comparison-table td {
    border-bottom-color: #4a5568;
}

body.dark-mode .comparison-table tr:hover {
    background: #1a202c;
}

body.dark-mode .comparison h3 {
    color: #e2e8f0;
}

body.dark-mode .comparison ol li {
    color: #cbd5e0;
}

body.dark-mode .warning-box {
    background: #2d3748;
    border-left-color: #f59e0b;
}

/* Dark Mode - New Unified Guide */
body.dark-mode .guide-section {
    background: #2d3748;
}

body.dark-mode .guide-section h2 {
    color: #cbd5e0;
}

body.dark-mode .guide-intro {
    color: #cbd5e0;
}

body.dark-mode .guide-card {
    background: #1e293b;
}

body.dark-mode .guide-description {
    color: #cbd5e0;
}

body.dark-mode .guide-steps {
    color: #e2e8f0;
}

body.dark-mode .guide-tip {
    background: #2d3748;
    color: #cbd5e0;
}

body.dark-mode #exec-policy-tip {
    color: #cbd5e0;
}


body.dark-mode .quick-start-steps strong {
    color: #ffffff;
    font-weight: 600;
}

body.dark-mode .quick-start-tip {
    color: #cbd5e0;
    border-top-color: #475569;
}

body.dark-mode .quick-start-tip strong {
    color: #f1f5f9;
    font-weight: 600;
}

body.dark-mode .comparison h2 {
    color: #f1f5f9;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Theme Toggle Button */
.theme-toggle {
    display: inline-block;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    position: relative;
}

.theme-toggle-btn i {
    margin: 0;
    padding: 0;
    line-height: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.theme-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.35);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

body.dark-mode .theme-toggle-btn {
    background: rgba(243, 156, 18, 0.3);
    border-color: rgba(243, 156, 18, 0.5);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

body.dark-mode .theme-toggle-btn:hover {
    background: rgba(243, 156, 18, 0.4);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.6);
}

/* Smooth transition for theme change */
body,
.method-card,
.comparison,
.features,
.guide-section,
.guide-card,
.guide-tip,
.warning-box,
.comparison-table tr {
    transition: all 0.3s ease;
}
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
        flex-direction: column;
        gap: 10px;
    }

    .theme-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .guide-columns {
        grid-template-columns: 1fr;
    }
}

/* Auth Styles - Compact Design */
.auth-bar {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 100;
}

.auth-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.auth-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

/* User Menu Button */
.user-menu-container {
    position: relative;
}

.user-menu-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 25px;
    padding: 6px 14px 6px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    transition: all 0.3s ease;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

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

.user-menu-btn .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff 0%, #e0e7ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9em;
    color: #667eea;
}

.user-menu-btn .user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.user-menu-btn .user-name {
    font-weight: 600;
    font-size: 0.9em;
}

.user-menu-btn .user-role {
    font-size: 0.7em;
    opacity: 0.8;
    text-transform: capitalize;
}

.user-menu-btn .dropdown-icon {
    margin-left: 4px;
    font-size: 0.7em;
    transition: transform 0.2s;
}

.user-menu-container.open .dropdown-icon {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    overflow: hidden;
}

.user-menu-container.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

body.dark-mode .user-dropdown {
    background: #1e293b;
}

.dropdown-header {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.dropdown-header .avatar-large {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3em;
    color: #667eea;
    margin: 0 auto 8px;
}

.dropdown-header .name {
    font-weight: 600;
    font-size: 1em;
}

.dropdown-header .role-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    margin-top: 5px;
    text-transform: capitalize;
}

.dropdown-menu {
    padding: 8px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    font-size: 0.9em;
    text-align: left;
}

body.dark-mode .dropdown-item {
    color: #e2e8f0;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

body.dark-mode .dropdown-item:hover {
    background: #334155;
}

.dropdown-item i {
    width: 18px;
    color: #667eea;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

body.dark-mode .dropdown-divider {
    background: #334155;
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.danger i {
    color: #ef4444;
}

.dropdown-item.danger:hover {
    background: #fef2f2;
}

body.dark-mode .dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

.dropdown-item.danger i {
    color: #ef4444;
}

.dropdown-section {
    padding: 8px 16px;
}

.modal-intro {
    text-align: center;
    color: #6b7280;
    margin-bottom: 25px;
    font-size: 1em;
}

body.dark-mode .modal-intro {
    color: #94a3b8;
}

.dropdown-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 8px;
}

body.dark-mode .dropdown-section-header {
    color: #94a3b8;
}

/* New Theme Selector: Visual Card Grid */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
}

.theme-card {
    cursor: pointer;
    text-align: center;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.theme-card:hover {
    transform: translateY(-2px);
    border-color: rgba(102, 126, 234, 0.5);
}

.theme-card.active {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.theme-card-preview {
    position: relative;
    height: 50px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #e2e8f0; /* Fallback for themes without preview */
}

body.dark-mode .theme-card-preview {
    background: #4a5568;
}

.theme-card-icon {
    font-size: 1.8em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    line-height: 1;
}

.theme-card-name {
    font-size: 0.8em;
    margin-top: 6px;
    display: block;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-mode .theme-card-name {
    color: #e2e8f0;
}

.theme-card-check {
    position: absolute;
    top: 4px;
    right: 4px;
    color: white;
    font-size: 1.1em;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.theme-card.active .theme-card-check {
    opacity: 1;
    transform: scale(1);
}

.theme-modal-box {
    max-width: 900px;
}

@media (max-width: 480px) {
    .user-menu-btn .user-details {
        display: none;
    }
    .user-menu-btn {
        padding: 6px 10px 6px 6px;
    }
}

/* Login Modal */
.login-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-box {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    position: relative;
}

.login-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.login-close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

body.dark-mode .login-box {
    background: #1e293b;
}

.login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.login-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.login-header p {
    margin: 10px 0 0;
    opacity: 0.9;
    font-size: 0.95em;
}

.login-body {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

body.dark-mode .form-group label {
    color: #e2e8f0;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

body.dark-mode .form-group input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    box-sizing: border-box;
    background: white;
    color: #333;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

body.dark-mode .form-group select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9em;
}

body.dark-mode .login-error {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

/* User Management Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-box {
    background: white;
    border-radius: 15px;
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.dark-mode .modal-box {
    background: #1e293b;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

/* User Table */
.user-table {
    width: 100%;
    border-collapse: collapse;
}

.user-table th,
.user-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

body.dark-mode .user-table th,
body.dark-mode .user-table td {
    border-bottom-color: #334155;
}

.user-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #667eea;
}

body.dark-mode .user-table th {
    background: #0f172a;
}

.user-table tr:hover {
    background: #f8f9fa;
}

body.dark-mode .user-table tr:hover {
    background: #0f172a;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.role-badge.admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.role-badge.user {
    background: #dcfce7;
    color: #16a34a;
}

body.dark-mode .role-badge.admin {
    background: rgba(29, 78, 216, 0.3);
}

body.dark-mode .role-badge.user {
    background: rgba(22, 163, 74, 0.3);
}

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.action-btn.edit {
    background: #dbeafe;
    color: #1d4ed8;
}

.action-btn.edit:hover {
    background: #bfdbfe;
}

.action-btn.delete {
    background: #fee2e2;
    color: #dc2626;
}

.action-btn.delete:hover {
    background: #fecaca;
}

body.dark-mode .action-btn.edit {
    background: rgba(29, 78, 216, 0.3);
}

body.dark-mode .action-btn.delete {
    background: rgba(220, 38, 38, 0.3);
}

.add-user-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-user-btn:hover {
    opacity: 0.9;
}

/* Add/Edit User Form */
.user-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

body.dark-mode .user-form {
    background: #0f172a;
}

.user-form h3 {
    margin: 0 0 15px;
    color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-save {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-cancel {
    background: #6b7280;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
}

/* Auth required overlay */
.auth-required-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.auth-required-box {
    text-align: center;
    color: white;
    padding: 40px;
}

.auth-required-box h2 {
    font-size: 2em;
    margin-bottom: 20px;
}

.auth-required-box p {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 30px;
}

/* Script Management Table */
.script-table {
    width: 100%;
    border-collapse: collapse;
}

.script-table th,
.script-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

body.dark-mode .script-table th,
body.dark-mode .script-table td {
    border-bottom-color: #334155;
}

.script-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #667eea;
}

body.dark-mode .script-table th {
    background: #0f172a;
}

.script-table tr:hover {
    background: #f8f9fa;
}

body.dark-mode .script-table tr:hover {
    background: #0f172a;
}

.premium-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.premium-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.premium-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 26px;
}

.premium-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.premium-toggle input:checked + .premium-slider {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
}

.premium-toggle input:checked + .premium-slider:before {
    transform: translateX(24px);
}

.premium-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.premium-status.premium {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    color: #1a202c;
}

.premium-status.public {
    background: #dcfce7;
    color: #16a34a;
}

body.dark-mode .premium-status.public {
    background: rgba(22, 163, 74, 0.3);
}

/* Admin toggle - blue theme instead of orange */
.admin-toggle input:checked + .admin-slider {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.kv-warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9em;
}

body.dark-mode .kv-warning {
    background: rgba(245, 158, 11, 0.2);
}

.kv-warning strong {
    color: #d97706;
}

/* Flexbox gap fallback for Safari < 14.1 */
@supports not (gap: 1px) {
    header h1 > * { margin-right: 15px; }
    header h1 > *:last-child { margin-right: 0; }
    .method-header > * { margin-right: 10px; margin-bottom: 10px; }
    .script-btn > * { margin-right: 8px; }
    .auth-btn > * { margin-right: 8px; }
    .user-menu-btn > * { margin-right: 10px; }
}

/* Utility class to hide elements. Placed at the end to ensure it overrides
   component-specific display properties without needing !important. This allows
   JS-driven inline styles (e.g., display: 'flex') to work correctly for modals. */
.hidden {
    display: none;
}