/* ==================== Variables & Reset ==================== */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1f2f52;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --tofu-color: #48bb78;
    --mofu-color: #ed8936;
    --bofu-color: #ed64a6;
    --success: #48bb78;
    --warning: #ed8936;
    --error: #fc8181;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ==================== Layout ==================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 28px;
    background: var(--accent-gradient);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo span {
    font-weight: 600;
    font-size: 16px;
}

.nav-menu {
    padding: 20px 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.schedule-info h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.schedule-item .day {
    color: var(--text-secondary);
    font-size: 14px;
}

.schedule-item .type {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.type.tofu {
    background: rgba(72, 187, 120, 0.2);
    color: var(--tofu-color);
}

.type.mofu {
    background: rgba(237, 137, 54, 0.2);
    color: var(--mofu-color);
}

.type.bofu {
    background: rgba(237, 100, 166, 0.2);
    color: var(--bofu-color);
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

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

.btn-generate {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    background: var(--accent-gradient);
    color: white;
    margin-top: 8px;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(102, 126, 234, 0.3);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.tofu-bg {
    background: rgba(72, 187, 120, 0.15);
}

.mofu-bg {
    background: rgba(237, 137, 54, 0.15);
}

.bofu-bg {
    background: rgba(237, 100, 166, 0.15);
}

.total-bg {
    background: rgba(102, 126, 234, 0.15);
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ==================== Posts Section ==================== */
.posts-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.filter-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-gradient);
    color: white;
}

.posts-table-container {
    overflow-x: auto;
}

.posts-table {
    width: 100%;
    border-collapse: collapse;
}

.posts-table th,
.posts-table td {
    padding: 16px 24px;
    text-align: left;
}

.posts-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.posts-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.posts-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.posts-table td {
    font-size: 14px;
}

.type-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.type-badge.TOFU,
.type-badge.Tofu {
    background: rgba(72, 187, 120, 0.2);
    color: var(--tofu-color);
}

.type-badge.MOFU,
.type-badge.Mofu,
.type-badge.mofu {
    background: rgba(237, 137, 54, 0.2);
    color: var(--mofu-color);
}

.type-badge.BOFU,
.type-badge.Bofu {
    background: rgba(237, 100, 166, 0.2);
    color: var(--bofu-color);
}

.theme-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.action-btn {
    padding: 8px 12px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

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

/* ==================== Views ==================== */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== Generate View ==================== */
.generate-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.generate-form-card,
.preview-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 28px;
}

.generate-form-card h2,
.preview-card h3 {
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-options {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
}

/* Preview Card */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 24px;
    min-height: 300px;
    white-space: pre-wrap;
    line-height: 1.8;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 250px;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.preview-meta {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.meta-item {
    padding: 6px 14px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==================== Calendar View ==================== */
.calendar-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 28px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.calendar-day {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 180px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.calendar-day:hover {
    border-color: var(--accent-primary);
}

.calendar-day.has-post {
    border-color: var(--success);
}

.calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.calendar-day-name {
    font-weight: 600;
    font-size: 14px;
}

.calendar-day-date {
    color: var(--text-muted);
    font-size: 12px;
}

.calendar-post-type {
    margin-bottom: 8px;
}

.calendar-post-title {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.generate-for-day {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}

.generate-for-day:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(102, 126, 234, 0.1);
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--error);
    color: white;
}

.modal-body {
    padding: 24px;
}

.modal-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-post-content {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 14px;
}

.modal-note {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
}

.modal-note h4 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== Loading Overlay ==================== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 35, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ==================== Responsive ==================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .generate-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }

    .sidebar .logo span,
    .sidebar .nav-item span:not(.nav-icon),
    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 16px;
    }

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

    .header {
        flex-direction: column;
        gap: 16px;
    }

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

/* ==================== Login Overlay ==================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    border: 1px solid var(--border-color);
    max-width: 400px;
    width: 90%;
}

.login-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.login-card h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-card>p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#login-form input {
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    text-align: center;
}

#login-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#login-form .btn {
    width: 100%;
    justify-content: center;
    padding: 16px;
    font-size: 16px;
}

.login-error {
    color: var(--error);
    margin-top: 16px;
    font-size: 14px;
}