/* D&D Master - Atmospheric Fantasy Theme */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=IM+Fell+English:ital@0;1&display=swap');

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

:root {
    --primary-color: #8b1a1a;
    --primary-dark: #5a0a0a;
    --secondary-color: #d4af37;
    --accent-color: #c9a961;
    --background-dark: #0d0d0d;
    --background-medium: #1a1410;
    --card-background: #2a211a;
    --card-hover: #332717;
    --text-light: #f5f1e8;
    --text-muted: #a89984;
    --border-color: #4a3f2f;
    --success-color: #3d8b40;
    --danger-color: #b33030;
    --info-color: #4a7ba7;
    --parchment: #f4e8d0;
}

body {
    font-family: 'IM Fell English', 'Georgia', serif;
    background: linear-gradient(135deg, var(--background-dark) 0%, var(--background-medium) 100%);
    background-attachment: fixed;
    color: var(--text-light);
    line-height: 1.7;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(139, 26, 26, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--secondary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

/* Navbar */
.navbar {
    background: linear-gradient(180deg, rgba(42, 33, 26, 0.95) 0%, rgba(26, 20, 16, 0.98) 100%);
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 1rem 0;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand h1 {
    color: var(--secondary-color);
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand h1::before {
    content: '⚔';
    font-size: 1.5rem;
    color: var(--primary-color);
}

.navbar-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    border: 1px solid transparent;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.5px;
}

.nav-link:hover {
    background: rgba(139, 26, 26, 0.3);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-link.active {
    background: var(--primary-color);
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(139, 26, 26, 0.5);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 2rem 0 4rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: glow 2s ease-in-out infinite alternate;
}

.hero p {
    font-size: 1.3rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px rgba(212, 175, 55, 0.5), 0 0 20px rgba(212, 175, 55, 0.3);
    }
    to {
        text-shadow: 0 0 20px rgba(212, 175, 55, 0.8), 0 0 30px rgba(212, 175, 55, 0.5);
    }
}

/* Cards */
.card {
    background: linear-gradient(145deg, var(--card-background) 0%, rgba(26, 20, 16, 0.95) 100%);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    transition: all 0.3s ease;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--secondary-color) 50%, transparent 100%);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(139, 26, 26, 0.4);
    border-color: var(--primary-color);
}

.card-header {
    background: linear-gradient(135deg, rgba(139, 26, 26, 0.3) 0%, rgba(139, 26, 26, 0.15) 100%);
    padding: 1.2rem 1.8rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.card-header h3::before {
    content: '◆';
    color: var(--primary-color);
    font-size: 0.8rem;
}

.card-body {
    padding: 2rem;
}

/* Login/Auth Form */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
    padding: 2rem 0;
}

.auth-card {
    max-width: 500px;
    width: 100%;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.auth-tab.active {
    color: var(--secondary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(139, 26, 26, 0.2);
}

.auth-tab:hover {
    color: var(--text-light);
    background: rgba(139, 26, 26, 0.1);
}

/* Forms */
.form-group {
    margin-bottom: 1.8rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.7rem;
    color: var(--secondary-color);
    font-weight: 600;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background: rgba(13, 13, 13, 0.6);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    font-size: 1rem;
    font-family: 'IM Fell English', serif;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(13, 13, 13, 0.8);
    box-shadow: 0 0 15px rgba(139, 26, 26, 0.3);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23d4af37' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

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

/* Buttons */
.btn {
    padding: 0.8rem 2rem;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--secondary-color);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    box-shadow: 0 8px 25px rgba(139, 26, 26, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #4a3f2f 0%, #2a211a 100%);
    color: var(--text-light);
    border-color: var(--border-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #2d6b2f 100%);
    color: white;
    border-color: #5ab55e;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #8b1f1f 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #2f5470 100%);
    color: white;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Alert Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

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

.alert-success {
    background: rgba(61, 139, 64, 0.2);
    border-color: var(--success-color);
    color: #a8e6aa;
}

.alert-danger {
    background: rgba(179, 48, 48, 0.2);
    border-color: var(--danger-color);
    color: #ffb3b3;
}

.alert-info {
    background: rgba(74, 123, 167, 0.2);
    border-color: var(--info-color);
    color: #a8d4ff;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

/* Character/Session Items */
.character-item, .session-item {
    background: linear-gradient(135deg, rgba(26, 20, 16, 0.8) 0%, rgba(42, 33, 26, 0.6) 100%);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
    border: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.character-item:hover, .session-item:hover {
    background: var(--card-hover);
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.character-info h4, .session-info h4 {
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
}

.character-stats, .session-stats {
    display: flex;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.character-stats span, .session-stats span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Session Actions */
.session-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.session-actions .btn-secondary,
.session-actions .btn-danger {
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    min-width: auto;
}

/* Game Narrative */
.game-narrative {
    background: linear-gradient(135deg, rgba(244, 232, 208, 0.05) 0%, rgba(201, 169, 97, 0.05) 100%);
    padding: 2rem;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    margin-bottom: 2rem;
    min-height: 150px;
    font-size: 1.1rem;
    line-height: 1.8;
    font-style: italic;
    position: relative;
}

.game-narrative::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 10px;
    font-size: 4rem;
    color: var(--secondary-color);
    opacity: 0.3;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: linear-gradient(145deg, var(--card-background) 0%, rgba(26, 20, 16, 0.98) 100%);
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 50px rgba(139, 26, 26, 0.5);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(135deg, rgba(139, 26, 26, 0.4) 0%, rgba(139, 26, 26, 0.2) 100%);
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.6rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.3s ease;
    padding: 0;
    width: 35px;
    height: 35px;
}

.close-btn:hover {
    color: var(--danger-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

/* Footer */
.footer {
    background: linear-gradient(180deg, transparent 0%, rgba(26, 20, 16, 0.8) 100%);
    border-top: 2px solid var(--primary-color);
    padding: 2rem 0;
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
}

.footer p {
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger-color); }
.text-success { color: var(--success-color); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none; }

/* Dice Roller Styles */
.dice-roller-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: 3px solid var(--secondary-color);
    box-shadow: 0 8px 25px rgba(139, 26, 26, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
}

.dice-roller-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 12px 35px rgba(139, 26, 26, 0.8);
}

.quick-dice-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.dice-btn {
    padding: 1rem;
    background: linear-gradient(135deg, var(--card-background) 0%, rgba(26, 20, 16, 0.9) 100%);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--secondary-color);
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dice-btn:hover {
    background: var(--primary-color);
    border-color: var(--secondary-color);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(139, 26, 26, 0.5);
}

.dice-result-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(139, 26, 26, 0.1) 100%);
    border: 3px solid var(--secondary-color);
    border-radius: 12px;
    padding: 2rem;
    margin: 1.5rem 0;
    text-align: center;
}

.animate-roll {
    animation: rollAnimation 0.5s ease-out;
}

@keyframes rollAnimation {
    0% {
        transform: scale(0.8) rotateY(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotateY(180deg);
    }
    100% {
        transform: scale(1) rotateY(360deg);
        opacity: 1;
    }
}

.dice-formula {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-family: 'Cinzel', serif;
}

.dice-rolls {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.roll-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: var(--card-background);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
}

.critical-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #2d6b2f 100%);
    border-color: #5ab55e;
    animation: pulse 1s infinite;
}

.critical-fail {
    background: linear-gradient(135deg, var(--danger-color) 0%, #8b1f1f 100%);
    border-color: #ff6b6b;
    animation: shake 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.chosen-roll {
    border-color: var(--success-color);
    border-width: 3px;
}

.unchosen-roll {
    opacity: 0.5;
}

.dice-total {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.total-label {
    font-size: 1rem;
    color: var(--text-muted);
    margin-right: 1rem;
}

.total-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--secondary-color);
    font-family: 'Cinzel', serif;
}

.total-value.critical {
    animation: glow 1s ease-in-out infinite alternate;
}

.dice-purpose {
    margin-top: 1rem;
    font-style: italic;
    color: var(--text-muted);
}

.dice-history-item {
    background: var(--background-dark);
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
    font-size: 0.9rem;
}

.dice-history-formula {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--secondary-color);
}

.dice-history-rolls {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.dice-history-total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-light);
}

.dice-history-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.dice-history-purpose {
    grid-column: 1 / -1;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    .navbar-brand h1 {
        font-size: 1.3rem;
    }

    .navbar-menu {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .character-item, .session-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .quick-dice-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .dice-history-item {
        grid-template-columns: auto 1fr auto;
        font-size: 0.85rem;
    }

    .dice-history-time {
        grid-column: 1 / -1;
        text-align: right;
    }

    .dice-roller-button {
        bottom: 1rem;
        right: 1rem;
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}
