/* CSS Variables */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --coffee-dark: #2d1b14;
    --coffee-medium: #5d4037;
    --crema: #e5a572;
    --crema-light: #f4c2a1;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: #475569;
    
    --font-primary: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0c1424 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* App Layout */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

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

/* Main Layout */
.main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Timer Section */
.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.timer-container {
    position: relative;
    width: 300px;
    height: 300px;
}

.progress-circle {
    position: relative;
    width: 100%;
    height: 100%;
}

.progress-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.3));
}

.progress-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 8;
}

.progress-bar {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565; /* 2 * π * 90 */
    stroke-dashoffset: 565;
    transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
}

/* Coffee Animation Container */
.coffee-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 200px;
    height: 200px;
}

/* Machine Components */
.machine {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.portafilter {
    width: 40px;
    height: 16px;
    background: linear-gradient(145deg, var(--bg-tertiary), var(--bg-secondary));
    border-radius: 8px;
    position: relative;
    box-shadow: var(--shadow-md);
}

.grounds {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 8px;
    background: linear-gradient(45deg, var(--coffee-dark), var(--coffee-medium));
    border-radius: 2px;
}

.group-head {
    width: 30px;
    height: 12px;
    background: linear-gradient(145deg, var(--secondary), #f97316);
    border-radius: 0 0 8px 8px;
    position: relative;
}

.spout {
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 50%;
}

/* Coffee Stream */
.coffee-stream {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.coffee-stream.active {
    opacity: 1;
}

.stream-drop {
    width: 2px;
    height: 6px;
    background: linear-gradient(to bottom, var(--crema), var(--coffee-dark));
    border-radius: 1px;
    animation: drip 0.8s ease-in-out infinite;
}

.stream-drop:nth-child(2) { animation-delay: 0.1s; }
.stream-drop:nth-child(3) { animation-delay: 0.2s; }

@keyframes drip {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(5px) scale(0.8); opacity: 0.8; }
    100% { transform: translateY(10px) scale(0.6); opacity: 0; }
}

/* Cup */
.cup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 8px 0;
}

.cup {
    width: 60px;
    height: 45px;
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border-radius: 0 0 30px 30px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e2e8f0;
}

.coffee-level {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, var(--coffee-medium) 0%, var(--coffee-dark) 100%);
    border-radius: 0 0 29px 29px;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* NAPRAWIONA CREMA - siedzi bezpośrednio na kawie */
.crema-level {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, 
        var(--crema-light) 0%, 
        var(--crema) 60%,
        rgba(229, 165, 114, 0.8) 100%);
    border-radius: 50% 50% 0 0;
    transition: height 0.8s ease-out 0.3s, bottom 0.6s ease-out;
    z-index: 2;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

/* Dodaj efekt bąbelków na cremie */
.crema-level::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: radial-gradient(circle at 25% 50%, 
        rgba(255, 255, 255, 0.5) 0%,
        transparent 40%),
        radial-gradient(circle at 75% 30%, 
        rgba(255, 255, 255, 0.4) 0%,
        transparent 35%),
        radial-gradient(circle at 50% 70%, 
        rgba(255, 255, 255, 0.3) 0%,
        transparent 25%);
    border-radius: 50%;
}

.cup-highlight {
    position: absolute;
    top: 8px;
    left: 12px;
    width: 12px;
    height: 16px;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 50%;
    transform: skew(-8deg);
    z-index: 3;
}

.saucer {
    width: 70px;
    height: 6px;
    background: linear-gradient(145deg, #f8fafc, #e2e8f0);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}

/* Steam */
.steam {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.steam.active {
    opacity: 1;
}

.steam-line {
    width: 1px;
    height: 12px;
    background: linear-gradient(to top, 
        rgba(255, 255, 255, 0.6) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%);
    border-radius: 1px;
    animation: steam-rise 1.5s ease-in-out infinite;
}

.steam-line:nth-child(1) { animation-delay: 0s; }
.steam-line:nth-child(2) { animation-delay: 0.3s; }
.steam-line:nth-child(3) { animation-delay: 0.6s; }

@keyframes steam-rise {
    0%, 100% { 
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    50% { 
        transform: translateY(-6px) scale(1.2);
        opacity: 0.3;
    }
}

/* Timer Display */
.timer-display {
    text-align: center;
    margin-top: 12px;
}

.time-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.time-unit {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.phase-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

/* Weight Card */
.weight-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
}

.weight-icon {
    font-size: 1.8rem;
}

.weight-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.weight-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.weight-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Controls Section */
.controls-section {
    display: flex;
    flex-direction: column;
}

.controls-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: fit-content;
    box-shadow: var(--shadow-xl);
}

/* Stats */
.stats-row {
    display: flex;
    gap: 1rem;
}

.stat {
    flex: 1;
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Settings */
.settings h3,
.phases h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.setting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.setting label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    width: 60px;
    transition: border-color 0.2s ease;
}

.setting input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.setting span {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.target-display {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    min-width: 60px;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.secondary-controls {
    display: flex;
    gap: 1rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
    flex: 1;
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-pause:hover:not(:disabled),
.btn-reset:hover {
    background: var(--border);
}

/* Phases */
.phase-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.phase {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.phase.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.phase-dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--border);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.phase.active .phase-dot {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.phase-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.phase-info span {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.phase-info small {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* Footer */
.footer {
    padding: 1rem 2rem;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

.session-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.session-stat {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .controls-section {
        order: -1;
    }
    
    .stats-row {
        flex-direction: column;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .secondary-controls {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .main {
        padding: 1rem;
    }
    
    .timer-container {
        width: 250px;
        height: 250px;
    }
    
    .time-value {
        font-size: 1.8rem;
    }
    
    .session-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* Poprawione stany animacji */
.brewing .coffee-level {
    height: 65%;
}

.brewing .crema-level {
    height: 12%;
    bottom: 65%;
}

.complete .coffee-level {
    height: 68%;
}

.complete .crema-level {
    height: 15%;
    bottom: 68%;
}
