/**
 * SBN Rhythm Library Frontend Styles
 * Mirrors the admin interface design
 */

/* Page Container */
.sbn-rhythm-library {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Page Header */
.sbn-rhythm-library-header {
    margin-bottom: 40px;
}

.sbn-rhythm-library-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #1d2327;
    margin-bottom: 8px;
}

.sbn-rhythm-library-intro {
    font-size: 16px;
    color: #646970;
    line-height: 1.6;
}

/* Category Headers */
.sbn-category-header {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #50575e;
    margin: 40px 0 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e85d3b;
}

.sbn-category-header:first-of-type {
    margin-top: 20px;
}

/* Patterns Grid */
.sbn-patterns-category {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .sbn-patterns-category {
        grid-template-columns: 1fr;
    }
}

/* Pattern Card */
.sbn-pattern-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sbn-pattern-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Pattern Header */
.sbn-pattern-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.sbn-pattern-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
}

.sbn-pattern-slug {
    font-size: 11px;
    background: #f0f0f1;
    padding: 3px 10px;
    border-radius: 12px;
    color: #646970;
    font-weight: 500;
    white-space: nowrap;
}

/* Pattern Info */
.sbn-pattern-info {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

.sbn-pattern-time,
.sbn-pattern-bpm {
    background: #f6f7f7;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    color: #50575e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sbn-pattern-time::before {
    content: '⏱';
    font-size: 14px;
}

.sbn-pattern-bpm::before {
    content: '♩=';
    font-size: 12px;
}

/* Pattern Description */
.sbn-pattern-desc {
    font-size: 14px;
    color: #646970;
    line-height: 1.6;
    margin: 0 0 16px;
}

/* Pattern Preview Container */
.sbn-pattern-preview {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e5e5;
}

/* Pattern Grid */
.sbn-pattern-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sbn-pattern-grid-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.sbn-pattern-grid-label {
    width: 60px;
    font-size: 11px;
    font-weight: 600;
    color: #646970;
    text-align: right;
    padding-right: 10px;
    line-height: 28px;
    flex-shrink: 0;
}

.sbn-pattern-grid-cells {
    display: flex;
    gap: 4px;
    flex: 1;
}

.sbn-pattern-grid-cell {
    width: 28px;
    height: 28px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    background: #fff;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

/* Measure Start Indicator */
.sbn-pattern-grid-cell.is-measure-start {
    margin-left: 12px;
    position: relative;
}

.sbn-pattern-grid-cell.is-measure-start::before {
    content: '';
    position: absolute;
    left: -8px;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: #999;
    border-radius: 1px;
}

.sbn-pattern-grid-cell.is-beat-label.is-measure-start::before {
    top: 0;
    bottom: 0;
}

/* Beat Labels */
.sbn-pattern-grid-cell.is-beat-label {
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    cursor: default;
}

/* Hit States */
.sbn-pattern-grid-cell.is-hit {
    background: #fff5f3;
    border-color: #e85d3b;
    color: #e85d3b;
}

.sbn-pattern-grid-cell.is-accent {
    background: #e85d3b;
    border-color: #d04a2a;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(232, 93, 59, 0.2);
}

.sbn-pattern-grid-cell.is-thumb {
    border-style: dashed;
    border-width: 2px;
}

.sbn-pattern-grid-cell.is-thumb.is-hit {
    background: #f5f5f5;
    border-color: #666;
    border-style: solid;
    color: #333;
}

/* Play Button */
.sbn-pattern-play-btn {
    width: 100%;
    padding: 10px 16px;
    background: #fff;
    border: 2px solid #e85d3b;
    border-radius: 6px;
    color: #e85d3b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sbn-pattern-play-btn:hover {
    background: #fff5f3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(232, 93, 59, 0.15);
}

.sbn-pattern-play-btn:active {
    transform: translateY(0);
}

.sbn-pattern-play-btn.is-playing {
    background: #e85d3b;
    border-color: #d04a2a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(232, 93, 59, 0.3);
}

.sbn-pattern-play-btn::before {
    content: '▶';
    font-size: 12px;
}

.sbn-pattern-play-btn.is-playing::before {
    content: '⏸';
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .sbn-pattern-card {
        padding: 16px;
    }
    
    .sbn-pattern-header h3 {
        font-size: 16px;
    }
    
    .sbn-pattern-grid-cell {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    .sbn-pattern-grid-label {
        width: 50px;
        font-size: 10px;
    }
}

/* Empty State */
.sbn-empty-state {
    text-align: center;
    padding: 80px 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-top: 20px;
}

.sbn-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.sbn-empty-state h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #1d2327;
}

.sbn-empty-state p {
    color: #646970;
    margin-bottom: 24px;
    font-size: 16px;
}

/* Loading State */
.sbn-loading {
    text-align: center;
    padding: 60px 20px;
    color: #646970;
}

.sbn-loading::before {
    content: '⏳';
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    animation: sbn-pulse 1.5s ease-in-out infinite;
}

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

/* Accessibility */
.sbn-pattern-play-btn:focus {
    outline: 2px solid #e85d3b;
    outline-offset: 2px;
}

.sbn-pattern-grid-cell:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

/* Print Styles */
@media print {
    .sbn-pattern-play-btn {
        display: none;
    }
    
    .sbn-pattern-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
