/* style.css - Enhanced Global Dark Theme with Mobile/Tablet Support */
:root { 
    --bg: #050505; 
    --pnl: #121212; 
    --brd: #333; 
    --txt: #e0e0e0; 
    --dim: #888; 
    --acc: #fff; 
    --hlt: #1a1a1a;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;
}

* {
    box-sizing: border-box;
}

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; 
    background: var(--bg); 
    color: var(--txt); 
    margin: 0; 
    padding: 0; 
    font-size: 14px; 
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================ */
/* RESPONSIVE TYPOGRAPHY */
/* ============================================ */

h1, h2, h3, h4 { 
    margin: 0; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    font-weight: 700; 
    color: #fff; 
}

h1 { font-size: clamp(1.8em, 5vw, 3em); }
h2 { font-size: clamp(1.4em, 4vw, 2em); }
h3 { font-size: clamp(1.2em, 3vw, 1.5em); }

/* ============================================ */
/* UTILITIES */
/* ============================================ */

.hidden { display: none !important; }
.lbl-sm { 
    font-size: 12px; 
    color: #888; 
    display: block; 
    margin-bottom: 5px; 
    text-transform: uppercase; 
    font-weight: bold;
}

/* ============================================ */
/* INPUTS & FORMS */
/* ============================================ */

input, select, textarea { 
    background: #080808; 
    border: 1px solid #444; 
    color: #fff; 
    padding: 12px; 
    border-radius: 4px; 
    width: 100%; 
    box-sizing: border-box; 
    font-family: inherit; 
    font-size: 0.95em;
    transition: border-color 0.2s, background 0.2s;
}

input:focus, select:focus, textarea:focus { 
    border-color: #888; 
    outline: none; 
    background: #111; 
}

@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px;
    }
}

button { 
    cursor: pointer; 
    transition: all 0.2s; 
    font-family: inherit;
    touch-action: manipulation; /* Better mobile tap */
}

button:active { 
    transform: translateY(1px); 
}

/* ============================================ */
/* BUTTONS */
/* ============================================ */

.btn-lr { 
    background: #fff; 
    color: #000; 
    border: none; 
    padding: 12px 20px; 
    font-weight: bold; 
    font-size: 0.75em; 
    border-radius: 4px; 
    text-transform: uppercase;
    min-height: 44px; /* Touch-friendly */
}

.btn-dark {
    background: #1a1a1a;
    color: #888;
    border: 1px solid #333;
}

.btn-dark:hover { 
    background: #333; 
    color: #fff; 
}

.btn-main {
    background: #4caf50;
    color: #fff;
    border: none;
    padding: 20px 40px;
    font-size: clamp(1em, 3vw, 1.2em);
    font-weight: bold;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-height: 60px;
}

.btn-main:hover { 
    background: #43a047; 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-main:active {
    transform: translateY(0);
}

.btn-alt {
    background: #1a1a1a;
    border: 1px solid #444;
}

.btn-alt:hover { 
    background: #333; 
    border-color: #666; 
}

@media (max-width: 768px) {
    .btn-main {
        padding: 18px 30px;
        max-width: 100%;
    }
}

/* ============================================ */
/* LOGIN VIEW - ENHANCED */
/* ============================================ */

#login-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    position: relative;
    overflow: hidden;
}

/* Animated background */
#login-view::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(76, 175, 80, 0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.3; }
    50% { transform: scale(1.1) rotate(180deg); opacity: 0.5; }
}

.login-box {
    background: rgba(18, 18, 18, 0.95);
    padding: 50px 40px;
    border: 1px solid #333;
    border-radius: 16px;
    max-width: 450px;
    width: 100%;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-box h1 {
    font-size: clamp(2em, 6vw, 3em);
    margin-bottom: 15px;
    background: linear-gradient(135deg, #4caf50, #8bc34a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box p {
    font-size: 1.1em;
    margin-bottom: 35px;
}

#login-btn {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: #fff;
    border: none;
    width: 100%;
    padding: 18px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(66, 133, 244, 0.3);
}

#login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(66, 133, 244, 0.5);
}

#login-btn:active {
    transform: translateY(0);
}

/* ::before emoji removed — emoji is already in the HTML button text */

@media (max-width: 768px) {
    .login-box {
        padding: 40px 30px;
    }
}

/* ============================================ */
/* CARDS & LAYOUT */
/* ============================================ */

.container { 
    max-width: 1000px; 
    margin: auto; 
    padding: 20px; 
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
}

.stat-card { 
    background: var(--pnl); 
    border: 1px solid var(--brd); 
    padding: 15px; 
    border-radius: 6px; 
    margin-bottom: 15px; 
}

.char-card { 
    cursor: pointer; 
    transition: all 0.2s; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #1a1a1a;
    padding: 15px;
    border: 1px solid #333;
    border-radius: 6px;
    margin-bottom: 10px;
    min-height: 70px;
}

.char-card:hover { 
    border-color: #fff; 
    background: #222;
    transform: translateX(4px);
}

.char-card:active {
    transform: translateX(2px);
}

@media (max-width: 768px) {
    .char-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .char-card button {
        width: 100%;
    }
}

.flex-row { 
    display: flex; 
    gap: 10px; 
    align-items: center; 
    flex-wrap: wrap;
}

.grid-2 { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 15px; 
}

/* ============================================ */
/* DYNAMIC CHOICE BOXES */
/* ============================================ */

.dyn-box {
    background: #080808;
    border: 1px solid #222;
    padding: 15px;
    border-radius: 6px;
}

.dyn-box select { 
    margin-bottom: 8px; 
}

/* ============================================ */
/* MODAL */
/* ============================================ */

.modal { 
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.85); 
    backdrop-filter: blur(4px); 
    padding: 20px; 
    box-sizing: border-box; 
    overflow-y: auto;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content { 
    background: #121212; 
    margin: 5% auto; 
    padding: 25px; 
    border: 1px solid #444; 
    width: 100%; 
    max-width: 500px; 
    border-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        margin: 10px auto;
        padding: 20px;
        max-width: 100%;
    }
}

/* ============================================ */
/* NOTIFICATION SYSTEM */
/* ============================================ */

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2196f3;
    color: #fff;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    font-weight: 500;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease-out;
    max-width: 350px;
    word-wrap: break-word;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-success {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
}

.notification-warning {
    background: linear-gradient(135deg, #ff9800, #ffa726);
}

.notification-error {
    background: linear-gradient(135deg, #f44336, #e57373);
}

.notification-info {
    background: linear-gradient(135deg, #2196f3, #42a5f5);
}

/* Save notification - compact and subtle */
.save-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
    z-index: 9999;
    font-weight: 600;
    font-size: 0.9em;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-notification.show {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        text-align: center;
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    .save-notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        justify-content: center;
    }
}

/* ============================================ */
/* LOADING OVERLAY */
/* ============================================ */

#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    z-index: 9998;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top: 4px solid #4caf50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #fff;
    font-size: 1.2em;
    font-weight: 500;
}

/* ============================================ */
/* RESPONSIVE DASHBOARD */
/* ============================================ */

#dashboard-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#dashboard-view > div {
    width: 100%;
    max-width: 500px;
}

@media (max-width: 768px) {
    #dashboard-view {
        padding: 15px;
    }
}

/* ============================================ */
/* TOUCH-FRIENDLY IMPROVEMENTS */
/* ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for mobile */
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    select, input {
        min-height: 44px;
    }
    
    .char-card {
        padding: 20px;
    }
}

/* ============================================ */
/* SCROLLBAR STYLING */
/* ============================================ */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox scrollbar */
html {
    scrollbar-width: thin;
    scrollbar-color: #333 #0a0a0a;
}

/* ============================================ */
/* PRINT STYLES */
/* ============================================ */

@media print {
    body {
        background: white;
        color: black;
    }
    
    .btn-lr, button, .modal {
        display: none !important;
    }
}

/* ============================================ */
/* ACCESSIBILITY */
/* ============================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #4caf50;
    outline-offset: 2px;
}

/* ============================================ */
/* HIGH CONTRAST MODE SUPPORT */
/* ============================================ */

@media (prefers-contrast: high) {
    :root {
        --bg: #000;
        --pnl: #111;
        --brd: #fff;
        --txt: #fff;
    }
    
    button, input, select {
        border: 2px solid #fff;
    }
}
/* ============================================ */
/* JOURNAL SYSTEM                               */
/* ============================================ */

.journal-entry-card {
    background: #121212;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #555;
    user-select: none;
}

.journal-entry-card:hover {
    background: #1a1a1a;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.journal-entry-card:active {
    transform: translateX(1px);
}

.journal-tag-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-pill-combat    { background: #3a1a1a; color: #ef9a9a; }
.tag-pill-roleplay  { background: #2a1a2a; color: #ce93d8; }
.tag-pill-discovery { background: #1a2a3a; color: #90caf9; }
.tag-pill-loot      { background: #2a2a1a; color: #ffe082; }
.tag-pill-general   { background: #1a1a1a; color: #aaa;    }

.journal-entry-card.tag-combat    { border-left-color: #ef5350; }
.journal-entry-card.tag-roleplay  { border-left-color: #ab47bc; }
.journal-entry-card.tag-discovery { border-left-color: #42a5f5; }
.journal-entry-card.tag-loot      { border-left-color: #ffca28; }
.journal-entry-card.tag-general   { border-left-color: #888;    }

.journal-entry-preview {
    color: #888;
    font-size: 0.85em;
    margin-top: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#journal-list {
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 4px;
}

#journal-list::-webkit-scrollbar       { width: 6px; }
#journal-list::-webkit-scrollbar-track { background: #0a0a0a; }
#journal-list::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* ============================================ */
/* CAST / UPCAST MODAL                          */
/* ============================================ */

.slot-level-btn {
    background: #1a1a1a;
    border: 2px solid #444;
    color: #ccc;
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.85em;
    font-weight: bold;
    min-width: 70px;
}

.slot-level-btn:hover {
    border-color: #a5d6a7;
    color: #a5d6a7;
    background: #0d1f0d;
}

.slot-level-btn.selected {
    border-color: #4caf50;
    background: #1b3a1b;
    color: #a5d6a7;
    box-shadow: 0 0 12px rgba(76,175,80,0.3);
}

.slot-level-btn.empty {
    border-color: #2a2a2a;
    color: #444;
    cursor: not-allowed;
}

.slot-level-btn.empty:hover {
    border-color: #2a2a2a;
    color: #444;
    background: #1a1a1a;
    transform: none;
}

.upcast-higher-box {
    background: #0a1a2a;
    border: 1px solid #1976d2;
    border-left: 4px solid #1976d2;
    padding: 12px 14px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 0.9em;
    color: #90caf9;
    white-space: pre-wrap;
    line-height: 1.5;
    animation: fadeIn 0.2s;
}

.upcast-base-level {
    background: #111;
    border: 1px solid #333;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.75em;
    color: #888;
    margin-left: 8px;
    font-weight: normal;
    vertical-align: middle;
}

#cast-slot-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

/* Mobile adjustments for new features */
@media (max-width: 600px) {
    .slot-level-btn {
        min-width: 60px;
        padding: 10px 8px;
        font-size: 0.8em;
    }

    .journal-entry-card {
        padding: 12px;
    }

    #journal-list {
        max-height: 55vh;
    }
}

/* ═══════════════════════════════════════════════════
   THEME SYSTEM — injected by themes.js
   ═══════════════════════════════════════════════════ */

/* Smooth transitions when switching themes */
body, .stat-card, .modal-content, header, .side-col, .main-col,
.tab-content, input, select, textarea, button {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* Parchment theme — light mode needs text overrides */
body.theme-parchment { color: #2c1a0e; }
body.theme-parchment h1, body.theme-parchment h2,
body.theme-parchment h3, body.theme-parchment h4 { color: #2c1a0e; }
body.theme-parchment input,
body.theme-parchment select,
body.theme-parchment textarea { color: #2c1a0e; }
body.theme-parchment .val { color: #5c3a1e; }
body.theme-parchment .lbl { color: #7a5c3e; }
body.theme-parchment .char-name { color: #5c3a1e; }

/* Theme picker widget */
.theme-picker-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
}
.theme-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
    line-height: 1;
}
.theme-btn:hover  { transform: scale(1.2); }
.theme-btn.active { border-color: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.4); }