/* Frequency Card Styles */

.frequency-card {
    flex: 0 0 320px;
    min-width: 320px;
    max-width: 333px; /* Compact max width */
    background: linear-gradient(135deg, var(--md-sys-color-surface-container) 0%, var(--md-sys-color-surface) 100%);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--md-sys-elevation-3);
    scroll-snap-align: center;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    touch-action: pan-y;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    overflow: visible; /* Allow natural height */
    height: auto;
    /* Ensure cards are immediately visible */
    will-change: transform;
    contain: layout style;
}

/* Medium screens (tablets) */
@media (min-width: 769px) and (max-width: 1024px) {
    .frequency-card {
        flex: 0 0 320px;
        min-width: 320px;
        max-width: 333px;
    }
    
    .add-card {
        flex: 0 0 320px;
        min-width: 320px;
        max-width: 333px;
    }
}

.frequency-card.dragging {
    cursor: grabbing;
    transform: scale(0.98) rotate(-2deg) !important;
    opacity: 0.85;
    box-shadow: var(--md-sys-elevation-5) !important;
    z-index: 1000;
    transition: none !important;
}

.frequency-card.dragging::before {
    opacity: 0 !important;
}

/* Disable hover effects on all cards when dragging */
body.dragging-active .frequency-card:hover {
    transform: none;
    box-shadow: var(--md-sys-elevation-3);
}

body.dragging-active .frequency-card:hover::before {
    opacity: 0;
}

/* Enhanced drag-over state */
.frequency-card.drag-over {
    border-left: 4px solid var(--md-sys-color-primary);
    background: linear-gradient(90deg, 
        rgba(187, 134, 252, 0.1) 0%, 
        transparent 20%);
    transform: translateX(8px);
    transition: all 0.2s ease;
}

.frequency-card.drag-over::before {
    opacity: 0.5 !important;
    background: linear-gradient(135deg, 
        rgba(187, 134, 252, 0.2) 0%, 
        rgba(3, 218, 198, 0.2) 100%);
}

.drag-placeholder {
    flex: 0 0 320px;
    min-width: 320px;
    height: 400px;
    background: var(--md-sys-color-surface-container);
    border: 2px dashed var(--md-sys-color-primary);
    border-radius: 24px;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.frequency-card {
    /* existing styles */
    transform-style: preserve-3d;
    perspective: 1000px;
}

.frequency-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(187, 134, 252, 0.1) 0%, 
        rgba(3, 218, 198, 0.1) 100%);
    border-radius: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.frequency-card:hover {
    transform: translateY(-8px) rotateX(-2deg);
    box-shadow: 
        0 20px 40px rgba(187, 134, 252, 0.3),
        0 10px 20px rgba(0, 0, 0, 0.2),
        var(--md-sys-elevation-5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.frequency-card:hover::before {
    opacity: 1;
}

.frequency-card > * {
    position: relative;
    z-index: 1;
}

.frequency-card.disabled {
    opacity: 0.5;
}

.frequency-card.disabled:hover {
    transform: none;
    box-shadow: var(--md-sys-elevation-3);
}

.frequency-card.disabled::before {
    display: none;
}

.frequency-card.disabled .card-body {
    pointer-events: none;
}

/* Playing state animation */
.frequency-card.playing {
    animation: subtlePulse 3s ease-in-out infinite;
}

.frequency-card.playing::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        var(--md-sys-color-primary),
        var(--md-sys-color-secondary));
    border-radius: 24px;
    opacity: 0.3;
    z-index: -1;
    animation: borderRotate 4s linear infinite;
}

@keyframes subtlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
}

@keyframes borderRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    position: relative;
    z-index: 5;
    min-height: 40px;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    font-size: 1.5rem;
    color: var(--md-sys-color-outline);
    padding: 4px 8px;
    user-select: none;
    transition: color 0.2s;
    letter-spacing: 2px;
}

.drag-handle:hover {
    color: var(--md-sys-color-primary);
}

.drag-handle:active {
    cursor: grabbing;
}

.card-title {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-title[data-editable="true"]:hover {
    background: rgba(187, 134, 252, 0.08);
}

.card-title-input {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container-highest);
    border: 2px solid var(--md-sys-color-primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    width: 100%;
    min-width: 150px;
    max-width: 100%;
    outline: none;
    box-sizing: border-box;
}

/* Card Controls */
.card-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.toggle-btn {
    width: 48px;
    height: 24px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease;
    z-index: 11;
    pointer-events: all;
}

.toggle-btn.active {
    background: var(--md-sys-color-primary);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: var(--md-sys-elevation-2);
    pointer-events: none;
}

.toggle-btn.active .toggle-thumb {
    transform: translateX(24px);
}

.delete-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    z-index: 11;
    pointer-events: all;
    position: relative;
}

.delete-btn:hover {
    background: var(--md-sys-color-error);
    transform: scale(1.1);
}

/* Card Body */
.card-body {
    margin-top: 20px;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    overflow: visible; /* Allow content to determine height */
}

.preset-selector {
    margin-bottom: 20px;
}

.preset-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    opacity: 0.87;
}

.preset-select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    font-size: 0.9rem;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-select:hover {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container-high);
}

.preset-select:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.12);
}

/* Control Groups */
.frequency-controls,
.custom-controls,
.volume-controls {
    margin-bottom: 20px;
}

.slider-control {
    margin-bottom: 20px;
    width: 100%;
    overflow: visible; /* Allow hover circle to overflow */
    padding: 0 10px;
}

.slider-control label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    opacity: 0.87;
}

.value-display {
    color: var(--md-sys-color-secondary);
    font-weight: 400;
    margin-left: 8px;
}

/* Card Footer */
.card-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.frequency-display {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.75rem;
}

.freq-label {
    color: var(--md-sys-color-on-surface);
    opacity: 0.7;
}

/* Removed conflict indicator - no longer needed */

/* Add Card Button */
.add-card {
    flex: 0 0 320px;
    min-width: 320px;
    max-width: 333px; /* Match compact card max width */
    height: auto; /* Match frequency card height behavior */
    min-height: 400px;
    border: 2px dashed var(--md-sys-color-outline-variant);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(187, 134, 252, 0.05);
    pointer-events: all;
    user-select: none;
    margin: 10px 100px 10px 0; /* Extra margin-right for mobile scroll */
    padding: 24px; /* Match frequency card padding */
    align-self: flex-start; /* Align to top instead of center */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .frequency-card {
        /* Width is controlled by layout.css for proper snapping */
        height: auto;
        min-height: auto;
        max-height: none;
        padding: 16px;
        margin: 10px 0; /* Only vertical margin */
        display: flex;
        flex-direction: column;
    }
    
    .add-card {
        /* Width is controlled by layout.css for proper snapping */
        height: auto;
        min-height: auto;
        padding: 16px;
        margin: 10px 0; /* Only vertical margin */
    }
    
    /* Hide drag handles on mobile */
    .drag-handle {
        display: none !important;
    }
    
    /* Adjust card header for mobile */
    .card-header {
        margin-bottom: 12px;
        min-height: 36px;
    }
    
    /* Adjust card body for mobile */
    .card-body {
        margin-top: 12px;
        flex: 1 0 auto; /* Allow to grow */
        overflow: visible; /* No scrolling */
        padding-bottom: 10px;
    }
    
    /* Compact sliders on mobile */
    .slider-container {
        margin-bottom: 14px;
    }
    
    .slider-container:last-child {
        margin-bottom: 8px;
    }
    
    /* Smaller fonts on mobile */
    .card-title {
        font-size: 1.1rem;
    }
    
    .slider-container label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    /* Ensure footer stays within card */
    .card-footer {
        margin-top: auto;
        padding-top: 8px;
    }
    
    /* Reduce preset selector spacing */
    .preset-selector {
        margin-bottom: 12px;
    }
    
    /* Compact volume controls on mobile */
    .volume-controls {
        margin-bottom: 12px;
    }
    
    /* Smaller frequency display text */
    .frequency-display {
        font-size: 0.7rem;
    }
}

.add-card:hover {
    border-color: var(--md-sys-color-primary);
    background: rgba(187, 134, 252, 0.1);
    transform: scale(1.02);
}

.add-card-icon {
    font-size: 3rem;
    color: var(--md-sys-color-primary);
    margin-bottom: 10px;
    line-height: 1;
}

.add-card-text {
    font-size: 1rem;
    color: var(--md-sys-color-on-surface);
    opacity: 0.9;
    font-weight: 500;
    white-space: nowrap; /* Prevent text wrapping */
}

/* Save Preset Button */
.save-preset-btn {
    width: 100%;
    padding: 12px;
    background: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.save-preset-btn:hover {
    background: var(--md-sys-color-secondary-container);
    transform: translateY(-1px);
    box-shadow: var(--md-sys-elevation-2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .frequency-card,
    .add-card {
        flex: 0 0 85vw;
        min-width: 85vw;
    }
}