/* ====================================
   Virtual Piano - Mobile Responsive CSS
   ==================================== */

/* Tool Page Common Styles */
.tool-page {
    padding-top: 0;
}

.breadcrumb {
    padding: 20px 0;
    font-size: 14px;
    color: #666;
}

.breadcrumb a {
    color: #666;
    text-decoration: none;
    transition: all 0.3s;
}

.breadcrumb a:hover {
    color: #667eea;
}

.breadcrumb .separator {
    margin: 0 10px;
    color: #ddd;
}

.breadcrumb .current {
    color: #333;
    font-weight: 600;
}

.tool-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 20px;
    text-align: center;
}

.tool-header-content {
    max-width: 800px;
    margin: 0 auto;
}

.tool-icon-large {
    font-size: 72px;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.tool-header h1 {
    font-size: 48px;
    font-weight: 900;
    margin-bottom: 15px;
    line-height: 1.2;
}

.tool-subtitle {
    font-size: 20px;
    opacity: 0.95;
    margin-bottom: 25px;
    line-height: 1.6;
}

.tool-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 16px;
}

.meta-separator {
    opacity: 0.5;
}

.tool-content {
    padding: 60px 20px;
    background: #f8f9fa;
}

/* Piano Container */
.piano-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 25px;
    box-shadow: 0 15px 60px rgba(0,0,0,0.12);
    overflow: hidden;
}

.piano-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 45px 30px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.piano-header::before {
    content: '🎹';
    position: absolute;
    font-size: 180px;
    opacity: 0.1;
    top: -30px;
    right: -30px;
    pointer-events: none;
}

.piano-header h2 {
    font-size: 38px;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.piano-header p {
    font-size: 16px;
    opacity: 0.95;
    margin: 0;
}

.piano-body {
    padding: 40px 30px;
}

/* Controls Section */
.piano-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #333;
    font-size: 14px;
}

.control-icon {
    font-size: 20px;
}

.control-group select {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.control-group select:hover {
    border-color: #667eea;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.control-group input[type="range"] {
    width: 120px;
    cursor: pointer;
    accent-color: #667eea;
}

#volumeValue {
    font-weight: 700;
    color: #667eea;
    min-width: 45px;
}

.control-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateY(-2px);
}

.control-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

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

/* NEW: Melodies Section */
.melodies-section {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.melodies-section h3 {
    font-size: 22px;
    color: #e65100;
    margin-bottom: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.melodies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.melody-btn {
    background: white;
    border: 2px solid #ff9800;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.melody-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
    border-color: #f57c00;
}

.melody-btn.playing {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    animation: pulse 1s infinite;
}

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

.melody-icon {
    font-size: 32px;
}

.melody-name {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
}

.melody-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.melody-status {
    font-size: 14px;
    color: #e65100;
    font-weight: 600;
    padding: 8px 15px;
    background: white;
    border-radius: 8px;
    min-height: 40px;
    display: flex;
    align-items: center;
}

/* NEW: Audio Upload Section */
.audio-upload-section {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.audio-upload-section h3 {
    font-size: 22px;
    color: #1565c0;
    margin-bottom: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-container {
    max-width: 600px;
}

.upload-area {
    background: white;
    border: 3px dashed #2196f3;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: #1565c0;
    background: #f5f5f5;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #1565c0;
    background: #e3f2fd;
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.upload-text {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.audio-info {
    background: white;
    border: 2px solid #2196f3;
    border-radius: 15px;
    padding: 25px;
}

.audio-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e3f2fd;
}

.audio-name {
    font-size: 16px;
    font-weight: 700;
    color: #1565c0;
    word-break: break-all;
}

.remove-audio-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.remove-audio-btn:hover {
    background: #d32f2f;
    transform: rotate(90deg);
}

.audio-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.audio-status {
    font-size: 14px;
    color: #1565c0;
    font-weight: 600;
    padding: 10px 15px;
    background: #e3f2fd;
    border-radius: 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Piano Keyboard - IMPROVED RESPONSIVE VERSION */
.piano-keyboard {
    position: relative;
    min-height: 260px;
    background: linear-gradient(to bottom, #1a1a1a 0%, #2d2d2d 100%);
    border-radius: 15px;
    padding: 30px 15px 20px;
    box-shadow: inset 0 10px 30px rgba(0,0,0,0.5);
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.piano-keys-container {
    position: relative;
    display: flex
;
    height: 200px;
    width: 100%;
}

/* White Keys - RESPONSIVE */
.piano-key.white {
    width: 60px;
    height: 200px;
    background: linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%);
    border: 2px solid #333;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.1s ease;
    box-shadow: 
        0 4px 6px rgba(0,0,0,0.3),
        inset 0 -4px 6px rgba(0,0,0,0.1);
    user-select: none;
    flex-shrink: 0; /* Prevent shrinking */
}

.piano-key.white:hover {
    background: linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%);
    transform: translateY(2px);
}

.piano-key.white.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(4px);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.3),
        inset 0 2px 8px rgba(0,0,0,0.3),
        0 0 20px rgba(102, 126, 234, 0.6);
}

/* Black Keys - RESPONSIVE */
.piano-key.black {
    width: 40px;
    height: 130px;
    background: linear-gradient(to bottom, #2a2a2a 0%, #000000 100%);
    border: 2px solid #000;
    border-radius: 0 0 5px 5px;
    cursor: pointer;
    position: absolute;
    z-index: 2;
    transition: all 0.1s ease;
    box-shadow: 
        0 6px 8px rgba(0,0,0,0.5),
        inset 0 -2px 4px rgba(255,255,255,0.1);
    user-select: none;
}

.piano-key.black:hover {
    background: linear-gradient(to bottom, #3a3a3a 0%, #1a1a1a 100%);
    transform: translateY(2px);
}

.piano-key.black.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(3px);
    box-shadow: 
        0 3px 5px rgba(0,0,0,0.5),
        inset 0 2px 6px rgba(0,0,0,0.5),
        0 0 20px rgba(118, 75, 162, 0.6);
}

/* Key Labels */
.key-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #999;
    pointer-events: none;
    user-select: none;
}

.piano-key.white .key-label {
    color: #666;
}

.piano-key.black .key-label {
    color: #999;
    bottom: 8px;
}

.key-label.note {
    font-size: 13px;
    bottom: 25px;
    color: #333;
}

.piano-key.black .key-label.note {
    color: #ccc;
}

/* Hide keyboard labels when disabled */
.piano-keyboard.hide-keys .key-label:not(.note) {
    display: none;
}

/* Active key label colors */
.piano-key.white.active .key-label {
    color: white;
}

.piano-key.black.active .key-label {
    color: white;
}

/* Keyboard Shortcuts Section */
.keyboard-shortcuts {
    background: #fff3e0;
    border-left: 5px solid #ff9800;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.keyboard-shortcuts h4 {
    color: #e65100;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 700;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.shortcut-item {
    font-size: 14px;
    color: #555;
    line-height: 1.8;
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    margin: 0 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-family: 'Courier New', monospace;
}

/* Piano Info Box */
.piano-info-box {
    background: #e3f2fd;
    border-left: 5px solid #2196f3;
    padding: 25px;
    border-radius: 12px;
}

.piano-info-box h4 {
    color: #1565c0;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 700;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    font-size: 14px;
    color: #555;
    line-height: 1.7;
}

.info-item strong {
    color: #1565c0;
    display: block;
    margin-bottom: 5px;
    font-size: 15px;
}

/* SEO Content Section */
.seo-content {
    padding: 80px 20px;
    background: white;
}

.content-article {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
}

.content-article h2 {
    font-size: 32px;
    font-weight: 800;
    margin-top: 50px;
    margin-bottom: 20px;
    color: #333;
}

.content-article h2:first-child {
    margin-top: 0;
}

.content-article h3 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 35px;
    margin-bottom: 15px;
    color: #333;
}

.content-article p {
    margin-bottom: 20px;
    color: #666;
    font-size: 16px;
}

.content-article ul,
.content-article ol {
    margin-bottom: 25px;
    padding-left: 30px;
    color: #666;
}

.content-article li {
    margin-bottom: 12px;
    line-height: 1.8;
}

.content-article strong {
    color: #333;
    font-weight: 700;
}

/* Related Tools */
.related-tools {
    max-width: 900px;
    margin: 60px auto 0;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 15px;
}

.related-tools h3 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 30px;
    text-align: center;
}

.related-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.related-tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 25px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
}

.related-tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.related-tool-card .tool-icon {
    font-size: 42px;
}

.related-tool-card .tool-name {
    font-weight: 700;
    color: #333;
}

/* Responsive Design */

/* Tablets & Small Laptops (1024px and below) */
@media (max-width: 1024px) {
    .piano-keyboard {
        padding: 25px 10px 15px;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 32px;
    }
    
    .tool-subtitle {
        font-size: 16px;
    }
    
    .tool-icon-large {
        font-size: 52px;
    }
    
    .tool-meta {
        font-size: 14px;
    }

    .content-article h2 {
        font-size: 26px;
    }
    
    .content-article h3 {
        font-size: 20px;
    }
    
    .related-tools-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .piano-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
    }

    .control-group {
        justify-content: space-between;
    }

    .control-buttons {
        justify-content: center;
    }

    .piano-header h2 {
        font-size: 28px;
    }
    
    .piano-body {
        padding: 30px 20px;
    }

    /* IMPROVED: Piano keys scale better on tablets */
    .piano-key.white {
        width: 52px;
        height: 180px;
    }

    .piano-key.black {
        width: 36px;
        height: 120px;
    }

    .shortcuts-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .melodies-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .melodies-section,
    .audio-upload-section {
        padding: 20px;
    }

    .upload-area {
        padding: 30px 20px;
    }

    .key-label {
        font-size: 10px;
    }

    .key-label.note {
        font-size: 12px;
        bottom: 20px;
    }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
    .tool-header {
        padding: 40px 15px;
    }

    .tool-header h1 {
        font-size: 28px;
    }

    .tool-content {
        padding: 40px 15px;
    }

    .piano-container {
        border-radius: 20px;
    }

    .piano-header {
        padding: 30px 20px;
    }

    .piano-header h2 {
        font-size: 24px;
    }

    .piano-body {
        padding: 25px 15px;
    }

    .piano-controls {
        padding: 15px;
        gap: 15px;
    }

    .control-group label {
        font-size: 13px;
    }

    .control-group select {
        padding: 8px 12px;
        font-size: 13px;
    }

    .control-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* IMPROVED: Smaller piano keys for mobile */
    .piano-keyboard {
        padding: 20px 10px 15px;
        min-height: 220px;
    }

    .piano-keys-container {
        height: 170px;
    }

    .piano-key.white {
        width: 44px;
        height: 170px;
    }

    .piano-key.black {
        width: 30px;
        height: 110px;
    }

    .key-label {
        font-size: 9px;
        bottom: 8px;
    }

    .key-label.note {
        font-size: 11px;
        bottom: 18px;
    }

    .melody-icon {
        font-size: 28px;
    }

    .melody-name {
        font-size: 12px;
    }

    .melodies-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px;
    }

    .upload-icon {
        font-size: 48px;
    }

    .upload-text {
        font-size: 16px;
    }

    .upload-hint {
        font-size: 13px;
    }

    .shortcuts-grid,
    .info-grid {
        gap: 12px;
    }

    .related-tools {
        padding: 25px 20px;
    }

    .related-tools h3 {
        font-size: 24px;
    }

    .related-tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* Very Small Mobile (360px and below) */
@media (max-width: 360px) {
    .piano-key.white {
        width: 38px;
        height: 150px;
    }

    .piano-key.black {
        width: 26px;
        height: 100px;
    }

    .piano-keys-container {
        height: 150px;
    }

    .key-label {
        font-size: 8px;
    }

    .key-label.note {
        font-size: 10px;
        bottom: 15px;
    }

    .melodies-grid {
        grid-template-columns: 1fr 1fr;
    }

    .melody-btn {
        padding: 12px;
    }

    .control-btn span {
        display: none; /* Hide emoji on very small screens */
    }
}

/* Animation for key press */
@keyframes keyPressGlow {
    0% {
        box-shadow: 0 0 0 rgba(102, 126, 234, 0);
    }
    50% {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    }
    100% {
        box-shadow: 0 0 0 rgba(102, 126, 234, 0);
    }
}

.piano-key.active {
    animation: keyPressGlow 0.4s ease-out;
}

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

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

/* Scroll Hint for Mobile */
@media (max-width: 768px) {
    .piano-keyboard::after {
        content: '⇄ Swipe to see all keys';
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 11px;
        color: rgba(255,255,255,0.6);
        white-space: nowrap;
        pointer-events: none;
        animation: fadeInOut 3s ease-in-out infinite;
    }
}

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

/* Better Touch Targets for Mobile */
@media (hover: none) and (pointer: coarse) {
    .piano-key.white {
        min-height: 150px; /* Ensure minimum touch target */
    }
    
    .piano-key.black {
        min-height: 100px;
    }
    
    .control-btn,
    .melody-btn {
        min-height: 44px; /* iOS minimum touch target */
        min-width: 44px;
    }
}