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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    line-height: 1.6;
    color: #2d3748;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
}

/* Container */
.container {
    max-width: 420px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 300;
}

.location-notice {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 300;
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Status Card */
.status-card {
    background: #f7fafc;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #4299e1;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #68d391;
    transition: all 0.3s ease;
}

.status-dot.recording {
    background: #fc8181;
    animation: pulse 1.5s infinite;
}

.status-dot.checking {
    background: #f6ad55;
    animation: pulse 1.5s infinite;
}

.status-dot.error {
    background: #fc8181;
}

.status-dot.requesting {
    background: #4299e1;
    animation: requestingPulse 1s infinite;
}

@keyframes requestingPulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

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

.status-text {
    font-weight: 500;
    font-size: 0.9rem;
}

.timer {
    font-family: "Courier New", monospace;
    font-size: 1.25rem;
    font-weight: 600;
    color: #4299e1;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.record-btn,
.stop-btn,
.cancel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.record-btn {
    background: #48bb78;
    color: white;
}

.record-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
}

.record-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.record-btn.recording {
    background: #ed8936;
    animation: recordingPulse 2s infinite;
}

@keyframes recordingPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(237, 137, 54, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(237, 137, 54, 0);
    }
}

.stop-btn {
    background: #e53e3e;
    color: white;
}

.stop-btn:hover:not(:disabled) {
    background: #c53030;
    transform: translateY(-2px);
}

.stop-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.cancel-btn {
    background: #cbd5e0;
    color: #2d3748;
}

.cancel-btn:hover:not(:disabled) {
    background: #a0aec0;
    transform: translateY(-2px);
}

.cancel-btn:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
    transform: none;
}

.record-icon,
.stop-icon,
.cancel-icon {
    width: 20px;
    height: 20px;
}

/* Progress Container */
.progress-container {
    margin: 1rem 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #718096;
}

/* Audio Preview */
.audio-preview {
    background: #f7fafc;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}

.audio-preview h3 {
    margin-bottom: 1rem;
    color: #2d3748;
    font-weight: 600;
}

.audio-player {
    width: 100%;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

/* Metadata Form */
.metadata-form {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #4a5568;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Upload Controls */
.upload-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.upload-btn,
.discard-btn,
.new-recording-btn,
.retry-btn,
.check-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 120px;
}

.upload-btn {
    background: #4299e1;
    color: white;
}

.upload-btn:hover {
    background: #3182ce;
    transform: translateY(-1px);
}

.upload-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.discard-btn {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.discard-btn:hover {
    background: #feb2b2;
}

.new-recording-btn,
.retry-btn {
    background: #48bb78;
    color: white;
}

.check-upload-btn {
    background: #4299e1;
    color: white;
}

.new-recording-btn:hover,
.retry-btn:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.check-upload-btn {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    min-width: auto;
}

.check-upload-btn:hover:not(:disabled) {
    background: #3182ce;
    transform: translateY(-1px);
}

.check-upload-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.upload-icon,
.discard-icon {
    width: 18px;
    height: 18px;
}

/* Upload Progress */
.upload-progress {
    text-align: center;
    padding: 2rem;
}

.upload-progress h3 {
    margin-bottom: 1.5rem;
    color: #2d3748;
}

.upload-status {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #718096;
}

/* Success/Error Messages */
.success-message,
.error-message {
    text-align: center;
    padding: 2rem;
    border-radius: 12px;
}

.success-message {
    background: #f0fff4;
    border: 1px solid #c6f6d5;
}

.error-message {
    background: #fed7d7;
    border: 1px solid #feb2b2;
}

.success-icon,
.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.success-message h3,
.error-message h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.success-message p,
.error-message p {
    margin-bottom: 1.5rem;
    color: #718096;
}

/* Footer */
.footer {
    background: #f7fafc;
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid #e2e8f0;
}

.footer-text {
    font-size: 0.8rem;
    color: #718096;
    line-height: 1.5;
}

/* Browser Warning */
.browser-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.warning-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
}

.warning-content h3 {
    color: #e53e3e;
    margin-bottom: 1rem;
}

.warning-content ul {
    text-align: left;
    margin-top: 1rem;
    padding-left: 1.5rem;
}

.warning-content li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }

    .container {
        min-height: calc(100vh - 1rem);
        border-radius: 16px;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .title {
        font-size: 1.5rem;
    }

    .main {
        padding: 1rem;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .record-btn,
    .stop-btn {
        width: 100%;
        max-width: 280px;
    }

    .upload-controls {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .status-card {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .progress-text {
        font-size: 0.75rem;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .status-card {
        border: 2px solid #000;
    }

    .form-group input,
    .form-group textarea {
        border: 2px solid #000;
    }
}

/* Focus indicators for keyboard navigation */
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Loading state */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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