/**
 * CalDAV Calendar - Custom Styles
 * Bootstrap 5 Erweiterungen
 */

/* ==========================================
   CSS Variables / Theme
   ========================================== */
:root {
    --primary-color: #0d6efd;
    --primary-dark: #0b5ed7;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   Global Styles
   ========================================== */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f8f9fa;
}

/* ==========================================
   Login Page
   ========================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-gradient);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 40px;
    animation: slideUp 0.5s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 36px;
    color: white;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.login-form .form-floating {
    position: relative;
}

.login-form .form-control {
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    padding: 16px;
    height: auto;
    font-size: 16px;
    transition: all 0.3s ease;
}

.login-form .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
}

.login-form .form-control:disabled {
    background-color: #f9fafb;
    opacity: 0.7;
}

.login-form .form-floating label {
    padding: 16px;
    color: #6b7280;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    z-index: 10;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--primary-color);
}

.login-btn {
    border-radius: 12px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    background: var(--bg-gradient);
    border: none;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 12px;
    color: #6b7280;
}

.security-badge i {
    color: var(--success-color);
}

.login-info {
    margin-top: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

/* Alert Animations */
.alert {
    border-radius: 12px;
    border: none;
}

.shake {
    animation: shake 0.5s ease-in-out;
}

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

/* ==========================================
   Dashboard Page
   ========================================== */
.dashboard-page {
    min-height: 100vh;
}

.dashboard-page .navbar {
    box-shadow: var(--card-shadow);
}

.dashboard-page .card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease;
}

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

.dashboard-page .card-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0 !important;
    padding: 16px 20px;
}

/* ==========================================
   Calendar Styles
   ========================================== */
#calendar {
    min-height: 600px;
}

.fc {
    font-family: inherit;
}

.fc-toolbar-title {
    font-size: 1.5rem !important;
    font-weight: 600;
}

.fc-button-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.fc-button-primary:hover {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.fc-button-primary:not(:disabled).fc-button-active,
.fc-button-primary:not(:disabled):active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

/* FullCalendar Navigation Buttons mit sichtbaren Pfeilen */
.fc .fc-prev-button,
.fc .fc-next-button {
    font-size: 1.2em !important;
    font-weight: bold !important;
    min-width: 40px !important;
}

.fc .fc-prev-button .fc-icon,
.fc .fc-next-button .fc-icon {
    font-size: 1.5em !important;
}

/* Fallback wenn Icons nicht laden - zeige Pfeile */
.fc .fc-icon-chevron-left::before {
    content: '‹' !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    font-size: 1.4em !important;
    font-weight: bold !important;
}

.fc .fc-icon-chevron-right::before {
    content: '›' !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    font-size: 1.4em !important;
    font-weight: bold !important;
}

.fc-day-today {
    background-color: rgba(13, 110, 253, 0.05) !important;
}

.fc-event {
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    border: none !important;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fc-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.fc-daygrid-event-dot {
    display: none;
}

/* Mini Calendar */
#miniCalendar {
    font-size: 12px;
}

#miniCalendar .fc-toolbar-title {
    font-size: 14px !important;
}

#miniCalendar .fc-daygrid-day-number {
    font-size: 12px;
    padding: 4px;
}

#miniCalendar .fc-col-header-cell-cushion {
    font-size: 11px;
}

#miniCalendar .fc-prev-button,
#miniCalendar .fc-next-button {
    padding: 2px 8px !important;
    font-size: 1em !important;
}

#miniCalendar .fc-icon-chevron-left::before,
#miniCalendar .fc-icon-chevron-right::before {
    font-size: 1.2em !important;
}

/* ==========================================
   Upcoming Events
   ========================================== */
.upcoming-events-list {
    max-height: 350px;
    overflow-y: auto;
}

.upcoming-event {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.upcoming-event:hover {
    background-color: #f9fafb;
}

.upcoming-event:last-child {
    border-bottom: none;
}

.event-color {
    width: 4px;
    height: 40px;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

.event-details {
    min-width: 0;
    flex: 1;
}

.event-title {
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-time {
    font-size: 12px;
    color: #6b7280;
}

/* ==========================================
   Event Modal
   ========================================== */
#eventModal .modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

#eventModal .modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 20px 24px;
}

#eventModal .modal-body {
    padding: 24px;
}

#eventModal .modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
}

#eventModal .form-control {
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

#eventModal .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-picker input[type="radio"] {
    display: none;
}

.color-picker label {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 3px solid transparent;
}

.color-picker label:hover {
    transform: scale(1.1);
}

.color-picker input[type="radio"]:checked + label {
    border-color: #1f2937;
    box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor;
}

/* Color Picker mit Legende */
.color-picker-legend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.color-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.color-option:hover {
    background-color: #f3f4f6;
}

.color-option input[type="radio"] {
    display: none;
}

.color-option label {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
}

.color-option:hover label {
    transform: scale(1.1);
}

.color-option input[type="radio"]:checked + label {
    border-color: #1f2937;
    box-shadow: 0 0 0 2px white, 0 0 0 3px #1f2937;
}

.color-option .color-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    /* Farbe wird inline gesetzt */
}

.color-option input[type="radio"]:checked ~ .color-label {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Responsive für kleine Bildschirme */
@media (max-width: 576px) {
    .color-picker-legend {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   Search Results
   ========================================== */
.search-result {
    transition: all 0.2s ease;
}

.search-result:hover {
    background-color: #f8f9fa;
    transform: translateX(4px);
}

/* ==========================================
   Stats Widget
   ========================================== */
#statsWidget {
    font-size: 14px;
}

/* ==========================================
   Toast Notifications
   ========================================== */
.toast {
    border-radius: 12px;
    border: none;
    box-shadow: var(--card-shadow-hover);
}

.toast-header {
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #e5e7eb;
}

/* ==========================================
   Loading Overlay
   ========================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow-hover);
}

/* ==========================================
   Progress Stacked (Stats)
   ========================================== */
.progress-stacked {
    border-radius: 8px;
    overflow: hidden;
}

.progress-stacked .progress-bar {
    font-size: 10px;
    font-weight: 600;
}

/* ==========================================
   Scrollbar Styling
   ========================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ==========================================
   Responsive Adjustments
   ========================================== */
@media (max-width: 768px) {
    .login-card {
        padding: 24px;
    }
    
    .login-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    #calendar {
        min-height: 400px;
    }
    
    .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }

    .upcoming-events-list {
        max-height: 200px;
    }
}

/* ==========================================
   Utility Classes
   ========================================== */
.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: all 0.3s ease;
}

/* Loading States */
.btn .spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Fade Animations */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

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

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

/* Pulse Animation for Sync Button */
.pulse {
    animation: pulse 1s infinite;
}

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   Icon Fallbacks (falls Bootstrap Icons nicht laden)
   ========================================== */
.bi {
    display: inline-block;
    vertical-align: -0.125em;
}

/* Fallback wenn Icons nicht geladen */
.icon-fallback-active .bi::before {
    content: "●";
    font-family: sans-serif;
    font-size: 0.8em;
}

/* Spezifische Fallbacks */
.icon-fallback-active .bi-calendar-check::before { content: "📅"; }
.icon-fallback-active .bi-person::before { content: "👤"; }
.icon-fallback-active .bi-lock::before { content: "🔒"; }
.icon-fallback-active .bi-eye::before { content: "👁"; }
.icon-fallback-active .bi-eye-slash::before { content: "👁"; }
.icon-fallback-active .bi-box-arrow-in-right::before { content: "→"; }
.icon-fallback-active .bi-check-circle::before { content: "✓"; }
.icon-fallback-active .bi-exclamation-triangle::before { content: "⚠"; }
.icon-fallback-active .bi-exclamation-circle::before { content: "!"; }
.icon-fallback-active .bi-shield-check::before { content: "🛡"; }
.icon-fallback-active .bi-shield-exclamation::before { content: "🛡"; }
.icon-fallback-active .bi-info-circle::before { content: "ℹ"; }
.icon-fallback-active .bi-arrow-repeat::before { content: "↻"; }
.icon-fallback-active .bi-plus-lg::before { content: "+"; }
.icon-fallback-active .bi-search::before { content: "🔍"; }
.icon-fallback-active .bi-person-circle::before { content: "👤"; }
.icon-fallback-active .bi-bar-chart::before { content: "📊"; }
.icon-fallback-active .bi-wifi::before { content: "📶"; }
.icon-fallback-active .bi-download::before { content: "⬇"; }
.icon-fallback-active .bi-box-arrow-right::before { content: "→"; }
.icon-fallback-active .bi-clock::before { content: "🕐"; }
.icon-fallback-active .bi-graph-up::before { content: "📈"; }
.icon-fallback-active .bi-arrow-clockwise::before { content: "↻"; }
.icon-fallback-active .bi-calendar-event::before { content: "📅"; }
.icon-fallback-active .bi-trash::before { content: "🗑"; }
.icon-fallback-active .bi-check-lg::before { content: "✓"; }
.icon-fallback-active .bi-geo-alt::before { content: "📍"; }
.icon-fallback-active .bi-x-lg::before { content: "✕"; }
.icon-fallback-active .bi-check-circle-fill::before { content: "✓"; }
.icon-fallback-active .bi-exclamation-circle-fill::before { content: "!"; }
.icon-fallback-active .bi-exclamation-triangle-fill::before { content: "⚠"; }
.icon-fallback-active .bi-info-circle-fill::before { content: "ℹ"; }
.icon-fallback-active .bi-calendar-x::before { content: "📅"; }
