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

/* ==========================================
   STACK GLOBAL MODERN DARK DESIGN SYSTEM
   ========================================== */

:root {
    color-scheme: dark;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-hover: #475569;
    --accent: #10b981;
    --accent-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --font-sans: 'Inter', 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
    color: var(--primary);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Top-level Layout Containers */
.container, #app:not(.button-grid), .content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Global Cards */
.card, #main-content, #measurements-container, .popup-content, .modal-content, .modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    color: var(--text-main);
}

/* Headers & Navigation Bar */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#main-tabs, .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.tabs-left, .tabs-right {
    display: flex;
    gap: 0.5rem;
}

/* Tab and Navigation Buttons */
.tab-button, .subtab-button, .control-button {
    padding: 0.35rem 0.65rem;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-button:hover, .subtab-button:hover, .control-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.tab-button.active, .subtab-button.active {
    color: var(--text-main);
    background-color: var(--border);
    border-color: var(--border-hover);
    font-weight: 600;
}

.tab-content, .subtab-content {
    display: none;
}

.tab-content.active, .subtab-content.active {
    display: block;
}

#options-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Buttons System */
.btn {
    padding: 0.35rem 0.65rem;
    border-radius: 0;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background-color: var(--border);
    color: var(--text-main);
    border-color: var(--border-hover);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
    color: #ffffff;
}

.btn-success {
    background-color: var(--accent);
    color: #ffffff;
}

.btn-success:hover {
    background-color: var(--accent-hover);
}

.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: #ffffff;
}

/* Form Controls & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

input, textarea, select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* Tables */
table, .verse-table, .source-table, .measurements-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background-color: rgba(15, 23, 42, 0.4);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Modals & Overlay Popups */
.modal, .popup, .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(6px);
}

.modal.active, .modal-overlay.active {
    display: flex;
}

.popup:not(.hidden) {
    display: flex;
}

/* Badges & Tags */
.badge, .translation-badge, .topic-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-primary, .translation-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.topic-tag {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Top Button */
.top-button {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 0.35rem 0.75rem;
    background-color: var(--primary);
    color: #ffffff;
    text-decoration: none;
    border-radius: 0;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.top-button:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

/* Dashboard Frontpage Grid of Buttons */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 950px;
    margin: 2rem auto;
    padding: 1rem;
}

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.25rem;
    font-size: 1.05rem;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 0;
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(16, 185, 129, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.button:hover::before, .button:focus::before {
    opacity: 1;
}

.button:hover, .button:focus {
    transform: translateY(-2px);
    border-color: var(--primary-light);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.2);
    color: #ffffff;
}

/* PWA Install Button */
.pwa-install-btn {
    display: block;
    width: calc(100% - 40px);
    max-width: 950px;
    margin: 1.5rem auto 0;
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    color: #ffffff;
    border: none;
    border-radius: 0;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    text-align: center;
}

.pwa-install-btn[hidden],
[hidden] {
    display: none !important;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container, #app:not(.button-grid), .content {
        padding: 1rem;
    }
    
    #main-tabs, .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .button-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
        padding: 1rem;
        margin: 1.5rem auto;
    }
    
    .button {
        font-size: 1rem;
        padding: 1.5rem 1rem;
    }
}