/* SWN Campaign Manager - Enhanced Styles */

/* CSS Custom Properties for consistent theming */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #95a5a6;
    --secondary-dark: #7f8c8d;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --dark-color: #2c3e50;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
    --border-radius: 8px;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.15);
    --transition: all 0.2s ease;
}

/* Form Styling */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input:invalid,
.form-group select:invalid {
    border-color: var(--danger-color);
}

.form-group .help-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Enhanced Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
    gap: 0.5rem;
    min-height: 44px; /* Better touch targets */
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

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

.btn-secondary {
    background: var(--secondary-color);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

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

.btn-success:hover {
    background: #219a52;
}

.btn-warning {
    background: var(--warning-color);
}

.btn-warning:hover {
    background: #e67e22;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 52px;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--light-bg);
    transition: var(--transition);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Table variants */
.table-striped tbody tr:nth-child(even) {
    background: rgba(248, 249, 250, 0.5);
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color);
}

/* Grid Layouts */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stats-row {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.stat-box {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-box:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-box label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-box:hover label {
    color: rgba(255, 255, 255, 0.8);
}

.stat-box .value {
    font-size: 1.25rem;
    font-weight: bold;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease-out;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transition: var(--transition);
}

.card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    margin: 0;
    color: var(--dark-color);
    font-size: 1.25rem;
    font-weight: 600;
}

.card-subtitle {
    margin: 0.5rem 0 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--dark-color);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-center {
    text-align: center;
}

/* Alerts and Messages */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    border-color: var(--success-color);
    color: #155724;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border-color: var(--warning-color);
    color: #856404;
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border-color: var(--danger-color);
    color: #721c24;
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    border-color: var(--primary-color);
    color: #0c5460;
}

/* Loading States */
.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

/* Character sheet specific */
.character-sheet .stat-box:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .stats-row {
        flex-wrap: wrap;
    }
    
    .stat-box {
        min-width: 80px;
        margin-bottom: 0.5rem;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .card {
        padding: 1rem;
    }
    
    .stats-row {
        flex-direction: column;
    }
}

/* HTMX Loading States */
.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-request.loading::after {
    content: " Loading...";
    color: var(--text-muted);
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

/* Navigation Enhancements */
.navbar {
    background: var(--dark-color);
    box-shadow: var(--shadow);
    border-bottom: 3px solid var(--primary-color);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.25rem;
    margin-right: 2rem;
}

.navbar-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white !important;
}

.nav-link.active {
    background: var(--primary-color);
    color: white !important;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle::after {
    content: " ▼";
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    min-width: 200px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

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

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--dark-color);
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--light-bg);
    color: var(--primary-color);
}

/* Filter Panel Enhancements */
.filter-panel {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.filter-panel h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
    font-size: 1.125rem;
}

.search-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Utility Classes */
.d-flex {
    display: flex;
}

.d-grid {
    display: grid;
}

.justify-content-between {
    justify-content: space-between;
}

.justify-content-center {
    justify-content: center;
}

.align-items-center {
    align-items: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

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

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

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* Badge Components */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-secondary {
    background: var(--secondary-color);
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

.badge-light {
    background: var(--light-bg);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

/* Form improvements */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Character grid hover effects */
.character-card {
    position: relative;
    overflow: hidden;
}

.character-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.character-card:hover::before {
    left: 100%;
}

/* Leveling System Styles */
.leveling-section {
    margin: 1.5rem 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-color);
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

.experience-display {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.exp-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.exp-info .label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.exp-info .value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-color);
}

.exp-bar {
    position: relative;
    height: 24px;
    background: var(--light-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.exp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
    transition: width 0.3s ease;
}

.exp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark-color);
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

/* Level Up Modal Styles */
.level-up-modal .modal-content {
    max-width: 600px;
}

.level-up-summary {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--success-color);
}

.benefits-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.benefits-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.benefits-list li:last-child {
    border-bottom: none;
}

.skill-allocation {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    background: white;
}

.skill-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.skill-row:last-child {
    border-bottom: none;
}

.skill-input {
    width: 80px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.points-remaining {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 600;
}

/* Modal Enhancements */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    color: var(--dark-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--light-bg);
    color: var(--dark-color);
}

.modal-body {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Hide modals by default */
[x-cloak] {
    display: none !important;
}

/* Psychic System Styles */
.psychic-skills {
    border-left: 4px solid #9c27b0;
    padding-left: 1rem;
    background: linear-gradient(90deg, rgba(156, 39, 176, 0.1), transparent);
}

.psychic-skill {
    background: rgba(156, 39, 176, 0.05);
}

.technique-allocation {
    margin-top: 1rem;
}

.discipline-section {
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 1rem;
    background: #fafafa;
}

.discipline-title {
    margin: 0 0 1rem 0;
    color: #9c27b0;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #9c27b0;
    padding-bottom: 0.5rem;
}

.technique-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.technique-row {
    display: flex;
    align-items: center;
}

.technique-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
}

.technique-row label:hover {
    background: rgba(156, 39, 176, 0.1);
}

.technique-row input[type="checkbox"] {
    margin: 0;
}

.points-summary {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
    border: 2px solid var(--border-color);
}

.points-remaining {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-weight: 600;
}

.points-remaining.general {
    color: var(--primary-color);
}

.points-remaining.expert {
    color: var(--success-color);
}

.points-remaining.psychic {
    color: #9c27b0;
}

.current-level {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .exp-info {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .section-title {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .section-actions {
        justify-content: center;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Print styles */
@media print {
    @page {
        size: letter;
        margin: 0.5in;
    }
    
    .character-sheet {
        font-size: 10pt;
    }
    
    .no-print {
        display: none !important;
    }
    
    .leveling-section {
        page-break-inside: avoid;
    }
}