/* FW Übungsplaner - Main Styles */

/* Base Variables */
:root {
    --fw-primary: #DC2626;
    --fw-primary-hover: #B91C1C;
    --fw-secondary: #64748B;
    --fw-success: #16A34A;
    --fw-warning: #CA8A04;
    --fw-danger: #EF4444;
    --fw-neutral: #F1F5F9;
    --fw-surface: #FFFFFF;
    --fw-text-main: #0F172A;
    --fw-text-muted: #64748B;
    --fw-border: #E2E8F0;
    --fw-radius: 0.5rem;
    --fw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

/* App Container */
.fw-app {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--fw-text-main);
    line-height: 1.5;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

/* Loading State */
.fw-loading {
    text-align: center;
    padding: 3rem;
}

.fw-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--fw-border);
    border-top-color: var(--fw-primary);
    border-radius: 50%;
    animation: fw-spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Error State */
.fw-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #991B1B;
    padding: 1rem;
    border-radius: var(--fw-radius);
    text-align: center;
}

/* Token Form */
.fw-token-form {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 2rem;
}

.fw-token-card {
    background: var(--fw-surface);
    border-radius: var(--fw-radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.fw-token-icon {
    color: var(--fw-primary);
    margin-bottom: 1rem;
}

.fw-token-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.fw-token-card p {
    color: var(--fw-text-muted);
    margin: 0 0 1.5rem;
}

.fw-token-input-form {
    text-align: left;
}

.fw-token-input-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.fw-token-input-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius);
    font-size: 1rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

.fw-token-input-form input:focus {
    outline: none;
    border-color: var(--fw-primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.fw-token-input-form button {
    width: 100%;
    padding: 0.75rem;
    background: var(--fw-primary);
    color: white;
    border: none;
    border-radius: var(--fw-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.fw-token-input-form button:hover {
    background: var(--fw-primary-hover);
}

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

.fw-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fw-header-icon {
    width: 40px;
    height: 40px;
    background: #FEE2E2;
    color: var(--fw-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fw-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.fw-header-subtitle {
    font-size: 0.75rem;
    color: var(--fw-text-muted);
}

/* Buttons */
.fw-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--fw-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

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

.fw-btn-primary:hover {
    background: var(--fw-primary-hover);
}

.fw-btn-secondary {
    background: var(--fw-surface);
    color: var(--fw-text-main);
    border: 1px solid var(--fw-border);
}

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

.fw-btn-danger {
    background: #FEF2F2;
    color: var(--fw-danger);
    border: 1px solid #FECACA;
}

.fw-btn-danger:hover {
    background: #FEE2E2;
}

.fw-btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
}

/* Cards */
.fw-card {
    background: var(--fw-surface);
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fw-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--fw-shadow);
}

.fw-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--fw-border);
    background: var(--fw-neutral);
}

.fw-card-body {
    padding: 1.25rem;
}

/* Termin Card */
.fw-termin-card {
    position: relative;
    padding-left: 0.375rem;
    cursor: pointer;
    margin-bottom: 1rem;
}

.fw-termin-stripe {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--fw-radius) 0 0 var(--fw-radius);
}

.fw-termin-stripe.geplant { background: #94A3B8; }
.fw-termin-stripe.bestaetigt { background: var(--fw-success); }
.fw-termin-stripe.abgesagt { background: var(--fw-danger); }

.fw-termin-content {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
}

.fw-termin-date {
    flex-shrink: 0;
    width: 60px;
    text-align: center;
    background: var(--fw-neutral);
    border-radius: var(--fw-radius);
    padding: 0.5rem;
}

.fw-termin-date-day {
    font-size: 1.5rem;
    font-weight: 700;
}

.fw-termin-date-month {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--fw-text-muted);
}

.fw-termin-info {
    flex: 1;
    min-width: 0;
}

.fw-termin-stats {
    flex-shrink: 0;
    text-align: right;
    font-size: 0.75rem;
}

/* Badges */
.fw-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.fw-badge-geplant { background: #F1F5F9; color: #475569; }
.fw-badge-bestaetigt { background: #DCFCE7; color: #166534; }
.fw-badge-abgesagt { background: #FEE2E2; color: #991B1B; }
.fw-badge-mga { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.fw-badge-ja { background: #DCFCE7; color: #166534; }
.fw-badge-vielleicht { background: #FEF9C3; color: #854D0E; }
.fw-badge-nein { background: #FEE2E2; color: #991B1B; }
.fw-badge-offen { background: #F1F5F9; color: #475569; }
.fw-badge-uebernommen { background: #DCFCE7; color: #166534; }
.fw-badge-abgelehnt { background: #FEE2E2; color: #991B1B; }

/* Ampel Indicator */
.fw-ampel {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.fw-ampel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.fw-ampel.genug { color: var(--fw-success); }
.fw-ampel.genug .fw-ampel-dot { background: var(--fw-success); }
.fw-ampel.fehlt { color: var(--fw-warning); }
.fw-ampel.fehlt .fw-ampel-dot { background: var(--fw-warning); }

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

.fw-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.fw-form-label .required {
    color: var(--fw-danger);
}

.fw-form-input,
.fw-form-select,
.fw-form-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fw-form-input:focus,
.fw-form-select:focus,
.fw-form-textarea:focus {
    outline: none;
    border-color: var(--fw-primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

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

/* Checkbox Group */
.fw-checkbox-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.fw-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.fw-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--fw-primary);
}

/* Radio Buttons as Cards */
.fw-radio-cards {
    display: flex;
    gap: 0.75rem;
}

.fw-radio-card {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--fw-border);
    border-radius: var(--fw-radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.fw-radio-card:hover {
    border-color: #CBD5E1;
}

.fw-radio-card.selected.ja { border-color: var(--fw-success); background: #DCFCE7; color: #166534; }
.fw-radio-card.selected.vielleicht { border-color: var(--fw-warning); background: #FEF9C3; color: #854D0E; }
.fw-radio-card.selected.nein { border-color: var(--fw-danger); background: #FEE2E2; color: #991B1B; }

/* Modal */
.fw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
}

.fw-modal-overlay.active {
    display: block;
}

.fw-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--fw-surface);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    z-index: 9999;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
}

.fw-modal.active {
    display: block;
}

.fw-modal-header {
    position: sticky;
    top: 0;
    background: var(--fw-surface);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--fw-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.fw-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.fw-modal-close {
    padding: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    color: var(--fw-text-muted);
}

.fw-modal-close:hover {
    background: var(--fw-neutral);
    color: var(--fw-text-main);
}

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

.fw-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--fw-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Table */
.fw-table-wrapper {
    overflow-x: auto;
}

.fw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

.fw-table th {
    background: var(--fw-neutral);
    font-weight: 500;
    color: var(--fw-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fw-table tbody tr:hover {
    background: #FAFAFA;
}

/* Actions Bar */
.fw-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.fw-actions-left {
    flex: 1;
    display: flex;
    gap: 0.5rem;
}

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

/* Filters */
.fw-filters {
    background: var(--fw-surface);
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: none;
}

.fw-filters.active {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* Stats Grid */
.fw-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: var(--fw-neutral);
    border-radius: var(--fw-radius);
    text-align: center;
}

.fw-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.fw-stat-value.success { color: var(--fw-success); }

.fw-stat-label {
    font-size: 0.75rem;
    color: var(--fw-text-muted);
}

/* Detail View */
.fw-detail-header {
    margin-bottom: 1.5rem;
}

.fw-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.fw-detail-item {
    display: flex;
    gap: 0.75rem;
}

.fw-detail-icon {
    color: var(--fw-text-muted);
    flex-shrink: 0;
}

.fw-detail-label {
    font-size: 0.75rem;
    color: var(--fw-text-muted);
}

.fw-detail-value {
    font-weight: 500;
}

/* Back Link */
.fw-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fw-text-muted);
    text-decoration: none;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.fw-back-link:hover {
    color: var(--fw-text-main);
}

/* Toast Notifications */
.fw-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fw-toast {
    padding: 0.75rem 1rem;
    border-radius: var(--fw-radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    animation: fw-toast-in 0.3s ease;
}

.fw-toast-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.fw-toast-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

@keyframes fw-toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.fw-empty {
    text-align: center;
    padding: 3rem;
    color: var(--fw-text-muted);
}

.fw-empty-icon {
    margin-bottom: 1rem;
}

/* Hidden */
.fw-hidden {
    display: none !important;
}

/* View Toggle */
.fw-view-toggle {
    display: inline-flex;
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius);
    overflow: hidden;
}

.fw-view-toggle .fw-btn {
    border: none;
    border-radius: 0;
    padding: 0.5rem 0.75rem;
}

.fw-view-toggle .fw-btn.active {
    background: var(--fw-primary);
    color: white;
}

.fw-view-toggle .fw-btn:not(.active):hover {
    background: var(--fw-neutral);
}

/* Cards List */
.fw-cards-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.fw-termin-card {
    position: relative;
    padding-left: 0.375rem;
    cursor: pointer;
}

.fw-termin-stripe {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--fw-radius) 0 0 var(--fw-radius);
}

.fw-termin-stripe.geplant { background: #94A3B8; }
.fw-termin-stripe.bestaetigt { background: var(--fw-success); }
.fw-termin-stripe.abgesagt { background: var(--fw-danger); }

.fw-termin-content {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
}

.fw-termin-date {
    flex-shrink: 0;
    width: 60px;
    text-align: center;
    background: var(--fw-neutral);
    border-radius: var(--fw-radius);
    padding: 0.5rem;
}

.fw-termin-date-day {
    font-size: 1.5rem;
    font-weight: 700;
}

.fw-termin-date-month {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--fw-text-muted);
}

.fw-termin-date-weekday {
    font-size: 0.65rem;
    color: var(--fw-text-muted);
}

.fw-termin-info {
    flex: 1;
    min-width: 0;
}

.fw-termin-stats {
    flex-shrink: 0;
    text-align: right;
    font-size: 0.75rem;
}

.fw-termin-actions {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--fw-border);
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 640px) {
    .fw-termin-content {
        flex-direction: column;
    }
    
    .fw-termin-date {
        width: auto;
        display: flex;
        gap: 0.5rem;
        justify-content: flex-start;
        align-items: baseline;
    }
    
    .fw-termin-stats {
        text-align: left;
    }
    
    .fw-radio-cards {
        flex-direction: column;
    }
    
    .fw-actions {
        flex-direction: column;
    }
    
    .fw-actions-left,
    .fw-actions-right {
        width: 100%;
    }
    
    .fw-btn {
        justify-content: center;
    }
    
    .fw-view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .fw-view-toggle .fw-btn {
        flex: 1;
        justify-content: center;
    }
}
