/* CSS Variables for theming */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1f1f3a;
    --text-primary: #e94560;
    --text-secondary: #a0a0a0;
    --text-muted: #6c757d;
    --border-color: #2d2d44;
    --accent-primary: #e94560;
    --accent-secondary: #533483;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 6px;
    --transition: all 0.3s ease;
}

[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --accent-primary: #dc3545;
    --accent-secondary: #6f42c1;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

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

header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.tab-btn:hover {
    background: var(--accent-secondary);
    color: white;
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.card h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

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

.full-width {
    grid-column: 1 / -1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-group.vertical {
    flex-direction: column;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Header avatar */
.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

.header-avatar-placeholder {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 2px solid var(--accent-primary);
}

/* Avatar section in character tab */
.avatar-section {
    text-align: center;
}

.avatar-display {
    margin-bottom: 1.5rem;
}

.avatar-display img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-primary);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

.avatar-placeholder-large {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    margin: 0 auto;
    border: 4px solid var(--border-color);
}

.avatar-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Google OAuth button */
.btn-google {
    background: #ffffff !important;
    color: #757575 !important;
    border: 1px solid #dadce0 !important;
    font-weight: 500;
}

.btn-google:hover {
    background: #f8f9fa !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="dark"] .btn-google {
    background: #ffffff !important;
    color: #757575 !important;
}

.divider {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    position: relative;
    background: var(--bg-card);
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.status-badge::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-badge.active {
    background: rgba(40, 167, 69, 0.2);
    color: var(--success);
}

.status-badge.active::before {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-badge.inactive {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger);
}

.status-badge.inactive::before {
    background: var(--danger);
}

.status-badge.loading {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

.status-badge.loading::before {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Logs */
.logs {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

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

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

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

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

.help-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Photos */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: var(--transition);
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background: rgba(233, 69, 96, 0.05);
}

.upload-area.dragover {
    border-color: var(--accent-primary);
    background: rgba(233, 69, 96, 0.1);
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.photo-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.photo-item:hover .photo-overlay {
    opacity: 1;
}

.photo-delete {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transform: translateX(150%);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

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

.notification.success {
    border-left: 4px solid var(--success);
}

.notification.error {
    border-left: 4px solid var(--danger);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    header h1 {
        font-size: 1.25rem;
    }
    
    .tabs {
        justify-content: center;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
/* Login page avatar */
.login-avatar-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-primary);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

/* Character header with inline avatar */
.character-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.character-header h2 {
    margin: 0;
}

.avatar-inline {
    position: relative;
    display: flex;
    align-items: center;
}

.avatar-inline img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s;
}

.avatar-inline img:hover {
    opacity: 0.8;
}

.avatar-inline-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-inline-placeholder:hover {
    border-color: var(--accent-primary);
    background: rgba(233, 69, 96, 0.1);
}

.avatar-inline-placeholder span {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

.avatar-delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.avatar-inline:hover .avatar-delete-btn {
    opacity: 1;
}

.avatar-delete-btn:hover {
    background: #c0392b;
}

#avatar-upload-progress {
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    width: 50px;
}

/* Default avatar emoji style */
.avatar-default {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.avatar-default:hover {
    background: rgba(233, 69, 96, 0.1);
    transform: scale(1.05);
}

/* Avatar wrapper with circle and outline */
.avatar-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid var(--accent-primary);
    transition: all 0.2s;
}

.avatar-wrapper:hover {
    border-color: var(--accent-primary);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.2s;
}

.avatar-wrapper:hover .avatar-img {
    filter: brightness(0.6);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.avatar-wrapper:hover .avatar-overlay {
    opacity: 1;
}

.avatar-plus {
    font-size: 1.5rem;
    color: white;
    font-weight: 300;
}

/* Updated avatar sizes - 75px (50% increase from 50px) */
.avatar-wrapper {
    width: 75px !important;
    height: 75px !important;
}

.avatar-wrapper .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain !important;
    background: var(--bg-tertiary);
}

.avatar-plus {
    font-size: 2rem !important;
}

#avatar-upload-progress {
    width: 75px !important;
}

/* FontAwesome icons in tabs */
.tab-btn i {
    margin-right: 0.5rem;
}

/* FontAwesome icons in headers */
.card h2 i {
    margin-right: 0.5rem;
    color: var(--accent-primary);
}

/* Three fields in one row */
.form-row-three {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-row-three .form-group {
    margin-bottom: 0;
}

.form-row-three label {
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .form-row-three {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-row-three .form-group {
        margin-bottom: 0.75rem;
    }
}

/* Strict three columns - equal 1/3 width */
.form-row-three {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-row-three .form-group {
    flex: 1 1 0 !important;
    width: 33.333% !important;
    min-width: 0;
    margin-bottom: 0;
}

.form-row-three .form-control {
    width: 100%;
}

/* Mobile - stack vertically */
@media (max-width: 600px) {
    .form-row-three {
        flex-direction: column;
    }
    
    .form-row-three .form-group {
        width: 100% !important;
        margin-bottom: 1rem;
    }
}

/* Two column layout */
.form-row-two {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-row-two .form-group {
    flex: 1 1 0;
    margin-bottom: 0;
}

/* Color picker styling */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker {
    width: 60px !important;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.color-value {
    font-family: monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .form-row-two {
        flex-direction: column;
    }
    
    .form-row-two .form-group {
        margin-bottom: 1rem;
    }
}
