/* Component Styles */

/* === Icon Component === */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    vertical-align: middle;
    transition: transform var(--duration-micro) var(--easing-default);
}

.icon--sun {
    display: block;
}

.icon--moon {
    display: none;
}

[data-theme="dark"] .icon--sun {
    display: none;
}

[data-theme="dark"] .icon--moon {
    display: block;
}

.icon--play {
    display: block;
}

.icon--pause {
    display: none;
}

/* === Button Components === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: all var(--duration-standard) var(--easing-default);
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
}

.btn:focus-visible {
    outline: none;
    border-color: var(--border-focus);
}

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

.btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: var(--shadow-subtle);
}

/* Button Variants */
.btn--primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    box-shadow: var(--shadow-subtle);
}

.btn--primary:not(:disabled):hover {
    background: var(--btn-primary-hover);
    box-shadow: var(--shadow-medium);
}

.btn--secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    box-shadow: var(--shadow-subtle);
}

.btn--secondary:not(:disabled):hover {
    background: var(--btn-secondary-hover);
}

.btn--ghost {
    background: var(--btn-ghost-bg);
    color: var(--btn-ghost-text);
}

.btn--ghost:not(:disabled):hover {
    background: var(--btn-ghost-hover);
}

/* Button Sizes */
.btn--small {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-base);
}

.btn--large {
    padding: var(--space-4) var(--space-6);
    font-size: var(--font-size-lg);
    border-radius: var(--radius-xl);
}

.btn--icon {
    padding: var(--space-3);
    min-width: auto;
    aspect-ratio: 1;
    border-radius: var(--radius-base);
    width: 48px; /* Consistent size across all screen sizes */
    height: 48px;
    font-size: 20px; /* Ensures icons are always 20px */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Icon Button Consistency === */

/* Ensure icons inside buttons maintain consistent size */
.btn--icon .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0; /* Prevent icons from shrinking */
}

/* Button States */
.btn--loading {
    pointer-events: none;
}

.btn--loading .btn__text {
    opacity: 0;
}

/* Preset Button */
.btn--preset {
    min-width: 60px;
    aspect-ratio: 1;
    padding: var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    transition: all var(--duration-standard) var(--easing-default);
}

.btn--preset:not(:disabled):hover {
    background: var(--accent-primary);
    color: var(--text-inverse);
    transform: scale(1.05);
}

.btn--preset.active {
    background: var(--accent-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-medium);
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
}

/* Control Button Animations */
.control-btn {
    position: relative;
    overflow: hidden;
}

.control-btn.running .icon--play {
    display: none;
}

.control-btn.running .icon--pause {
    display: block;
}

/* Button Text */
.btn__text {
    transition: opacity var(--duration-micro) var(--easing-default);
}

/* === Progress Ring Component === */
.progress-ring__background {
    opacity: 0.2;
}

.progress-ring__progress {
    transition: stroke-dashoffset var(--duration-standard) var(--easing-default);
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.3));
}

/* Progress ring states */
.progress-ring.completed .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.5));
}

.progress-ring.warning .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.5));
}

.progress-ring.danger .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.5));
}

/* === Form Components === */
.setting-select {
    padding: var(--space-2) var(--space-3);
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-base);
    font-size: var(--font-size-sm);
    transition: all var(--duration-standard) var(--easing-default);
    min-width: 120px;
}

.setting-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    outline: none;
    transition: background var(--duration-standard) var(--easing-default);
}

.setting-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: var(--shadow-subtle);
    transition: all var(--duration-standard) var(--easing-default);
}

.setting-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.setting-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-subtle);
    transition: all var(--duration-standard) var(--easing-default);
}

.setting-range::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.setting-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    cursor: pointer;
    position: relative;
    transition: all var(--duration-standard) var(--easing-default);
}

.setting-checkbox:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.setting-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
}

.setting-checkbox:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Time Input Component */
.time-input__field {
    width: 80px;
    padding: var(--space-3);
    text-align: center;
    background: var(--input-bg);
    color: var(--input-text);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    font-family: var(--font-family-monospace);
    transition: all var(--duration-standard) var(--easing-default);
}

.time-input__field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.time-input__field:invalid {
    border-color: var(--danger);
}

/* === Utility Components === */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === Tooltip Component === */
.tooltip {
    position: relative;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-standard) var(--easing-default);
    z-index: var(--z-tooltip);
}

.tooltip::before {
    content: attr(data-tooltip);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-base);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    margin-bottom: var(--space-2);
}

.tooltip::after {
    content: '';
    border: 5px solid transparent;
    border-top-color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
}

/* === Badge Component === */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.badge--success {
    background: var(--success);
}

.badge--warning {
    background: var(--warning);
}

.badge--danger {
    background: var(--danger);
}

/* === Notification Component === */
.notification {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    max-width: 400px;
    padding: var(--space-4);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elevated);
    z-index: var(--z-toast);
    transform: translateX(120%);
    transition: transform var(--duration-emphasized) var(--easing-smooth);
}

.notification.visible {
    transform: translateX(0);
}

.notification--success {
    border-left: 4px solid var(--success);
}

.notification--warning {
    border-left: 4px solid var(--warning);
}

.notification--danger {
    border-left: 4px solid var(--danger);
}

/* === Accessibility Enhancements === */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .progress-ring__progress,
    .setting-range::-webkit-slider-thumb,
    .setting-range::-moz-range-thumb,
    .setting-checkbox,
    .time-input__field,
    .notification {
        transition: none !important;
    }
    
    .spinner {
        animation: none !important;
        border-top-color: transparent !important;
        border-right-color: currentColor !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .progress-ring__background {
        opacity: 0.5;
    }
    
    .setting-checkbox {
        border-width: 3px;
    }
    
    .time-input__field {
        border-width: 3px;
    }
}

/* === Focus Management === */
.focus-trap {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* === Mobile Enhancements === */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        box-shadow: var(--shadow-subtle);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .tooltip:hover::before,
    .tooltip:hover::after {
        opacity: 0;
    }
}

/* === Mobile Button Optimizations === */
@media (max-width: 480px) {
    .btn {
        padding: var(--space-3) var(--space-4);
        min-height: 44px; /* Apple's minimum touch target recommendation */
        font-size: var(--font-size-base);
    }
    
    .btn--large {
        padding: var(--space-4) var(--space-5);
        min-height: 52px; /* Slightly larger for primary actions */
        font-size: var(--font-size-lg);
    }
    
    .btn--preset {
        min-height: 44px;
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
        font-weight: var(--font-weight-bold);
        border-radius: var(--radius-base);
    }
    
    /* Improve touch feedback */
    .btn:not(:disabled):active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* === Dark Mode Specific Adjustments === */
[data-theme="dark"] .progress-ring__progress {
    filter: drop-shadow(0 0 8px rgba(129, 140, 248, 0.4));
}

[data-theme="dark"] .progress-ring.completed .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(52, 211, 153, 0.6));
}

[data-theme="dark"] .progress-ring.warning .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.6));
}

[data-theme="dark"] .progress-ring.danger .progress-ring__progress {
    filter: drop-shadow(0 0 12px rgba(248, 113, 113, 0.6));
}

/* === Print Specific Components === */
@media print {
    .btn,
    .tooltip,
    .notification,
    .spinner {
        display: none !important;
    }
    
    .progress-ring__progress {
        stroke: #000 !important;
    }
}

/* === Button Text Color Fixes === */

/* Ensure primary button text is always white for good contrast */
.btn--primary {
    color: #ffffff !important;
}

.btn--primary:not(:disabled):hover {
    color: #ffffff !important;
}

.btn--primary .btn__text {
    color: #ffffff !important;
}

/* Ensure primary button icons are also white */
.btn--primary .icon {
    stroke: #ffffff !important;
    color: #ffffff !important;
}
