/* Calendar PoC - Mobile-First Styling */

/* ===== CSS VARIABLES ===== */
:root {
    /* Kategoriefarben */
    --cat-ff: #FF8C00;         /* Orange */
    --cat-stefi: #DC143C;      /* Rot */
    --cat-koerper: #9370DB;    /* Violett */
    --cat-hh: #4169E1;         /* Blau */
    --cat-mm: #32CD32;         /* Grün */
    --cat-bier: #FFD700;       /* Gelb */
    --cat-undefined: #808080;  /* Grau */

    /* UI Colors */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #EEEEEE;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border: #DDDDDD;
    --border-light: #EEEEEE;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Touch Targets */
    --touch-min: 44px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* ===== RESET & GLOBAL ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    touch-action: manipulation;

    /* Häppchen 14: Safe area support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select {
    font-family: inherit;
    font-size: inherit;
}

/* ===== TOP-BAR ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow);
}

.week-number {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-add {
    width: var(--touch-min);
    height: var(--touch-min);
    border-radius: 50%;
    background: var(--cat-stefi);
    color: white;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px var(--shadow);
}

.btn-add:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-add:active {
    transform: scale(0.95);
}

/* ===== MINI-WOCHENÜBERSICHT ===== */
.mini-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
}

.mini-week__day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-min);
    position: relative;
    overflow: hidden;

    /* Häppchen 14: Better touch feedback */
    -webkit-tap-highlight-color: transparent;
}

.mini-week__day:hover {
    transform: scale(1.05);
}

.mini-week__day:active {
    transform: scale(0.95);
}

.mini-week__day.active {
    box-shadow: 0 0 0 3px var(--cat-stefi);
}

.mini-week__day.today {
    border: 2px solid var(--cat-stefi);
}

.mini-week__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.mini-week__date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mini-week__colors {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 33%;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ===== DETAIL-VIEW ===== */
.detail-view {
    background: var(--bg-primary);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    position: sticky;
    top: 68px; /* Height of top-bar */
    z-index: 90;
}

.btn-nav {
    width: var(--touch-min);
    height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

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

.btn-nav:active {
    transform: scale(0.9);
}

.current-date {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    flex: 1;
}

/* ===== TIMELINE ===== */
.timeline-container {
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 220px); /* Adjust based on headers */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;

    /* Häppchen 14: Smooth scrolling optimization */
    overscroll-behavior-y: contain;
    scroll-snap-type: y proximity;
}

.timeline {
    position: relative;
    height: calc(96 * 40px); /* 96 slots * 40px each */
    padding-left: 60px;
}

.timeline__slot {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    border-bottom: 1px solid var(--border-light);
}

.timeline__slot:nth-child(4n) {
    border-bottom: 1px solid var(--border);
}

.timeline__label {
    position: absolute;
    left: 8px;
    top: -10px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 600;
    background: var(--bg-primary);
    padding: 0 4px;
}

/* ===== BLOCKS ===== */
.blocks-container {
    position: absolute;
    top: 0;
    left: 60px;
    right: 0;
    height: 100%;
    pointer-events: none;
}

.block {
    position: absolute;
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    pointer-events: auto;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 2px 4px var(--shadow);
    user-select: none;
    -webkit-user-select: none;
    color: white;

    /* Häppchen 14: Performance optimization */
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
}

.block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.block:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

.block__header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-xs);
}

.block__icon {
    font-size: 16px;
    flex-shrink: 0;
    opacity: 0.9;
}

.block__title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
}

.block__time {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 2px;
}

.block__resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    touch-action: none;
}

.block__resize-handle::after {
    content: '';
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}

/* Kategoriefarben */
.block[data-category="ff"] { background-color: var(--cat-ff); }
.block[data-category="stefi"] { background-color: var(--cat-stefi); }
.block[data-category="koerper"] { background-color: var(--cat-koerper); }
.block[data-category="hh"] { background-color: var(--cat-hh); }
.block[data-category="mm"] { background-color: var(--cat-mm); }
.block[data-category="bier"] { background-color: var(--cat-bier); }
.block[data-category="undefined"] { background-color: var(--cat-undefined); }

/* Transition-Blur Effect (Häppchen 12) - only for FF, MM, Bier */
.block[data-category="ff"],
.block[data-category="mm"],
.block[data-category="bier"] {
    position: relative;
    overflow: hidden;
}

.block[data-category="ff"]::before,
.block[data-category="mm"]::before,
.block[data-category="bier"]::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 ease;
}

.block[data-category="ff"]:hover::before,
.block[data-category="mm"]:hover::before,
.block[data-category="bier"]:hover::before {
    left: 100%;
}

/* Subtle backdrop blur on touch */
.block[data-category="ff"]:active,
.block[data-category="mm"]:active,
.block[data-category="bier"]:active {
    backdrop-filter: blur(2px);
    background-blend-mode: overlay;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    max-width: 90vw;
    width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn var(--transition-normal);
}

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

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.block-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--cat-stefi);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.btn-submit {
    padding: var(--spacing-md);
    background: var(--cat-stefi);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    min-height: var(--touch-min);
}

.btn-submit:hover {
    background: #C41E3A;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

.btn-delete {
    padding: var(--spacing-md);
    background: var(--text-tertiary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    min-height: var(--touch-min);
    margin-top: var(--spacing-sm);
}

.btn-delete:hover {
    background: #C41E3A;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn-delete:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.no-scroll {
    overflow: hidden;
}
