@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
    /* Material Design 3 Color Tokens */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    --md-sys-color-background: #FFFBFE;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-inverse-surface: #313033;
    --md-sys-color-inverse-on-surface: #F4EFF4;
    
    /* Success and warning colors */
    --md-sys-color-success: #0F9D58;
    --md-sys-color-warning: #FF9800;
    
    /* Animation durations */
    --duration-short: 200ms;
    --duration-medium: 300ms;
    --duration-long: 500ms;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Focus management for accessibility */
*:focus {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    padding: 16px;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.app-header {
    text-align: center;
    padding: 24px 0;
    position: relative;
}

.app-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 32px;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}

.app-subtitle {
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 16px;
}

.online-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all var(--duration-short) ease;
}

.online-status.online {
    background-color: rgba(15, 157, 88, 0.1);
    color: var(--md-sys-color-success);
}

.online-status.offline {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: box-shadow var(--duration-short) ease;
}

.card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.card-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 20px;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.permission-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background-color: var(--md-sys-color-surface);
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant);
    transition: all var(--duration-short) ease;
}

.permission-item:hover {
    border-color: var(--md-sys-color-outline);
}

.permission-icon {
    width: 24px;
    height: 24px;
    color: var(--md-sys-color-on-surface-variant);
}

.permission-status {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}

.status-granted {
    background-color: rgba(15, 157, 88, 0.1);
    color: var(--md-sys-color-success);
}

.status-denied {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.status-pending {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-outline);
}

.retry-permission {
    padding: 4px 8px;
    border: 1px solid var(--md-sys-color-outline);
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-short) ease;
}

.retry-permission:hover {
    background-color: var(--md-sys-color-primary-container);
}

.data-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.data-group {
    background-color: var(--md-sys-color-surface);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.data-group-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 14px;
    color: var(--md-sys-color-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.data-item:last-child {
    margin-bottom: 0;
}

.data-label {
    color: var(--md-sys-color-on-surface-variant);
}

.data-value {
    font-family: 'Roboto Mono', monospace;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    min-width: 80px;
    text-align: right;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 20px;
    border: none;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--duration-short) ease;
    text-decoration: none;
    min-height: 40px;
    position: relative;
    overflow: hidden;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--duration-short) ease;
}

.button:hover::before {
    opacity: 0.08;
}

.button:active::before {
    opacity: 0.12;
}

.button-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.button-primary:hover {
    box-shadow: 0 2px 8px rgba(103, 80, 164, 0.3);
}

.button-secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.button-secondary:hover {
    box-shadow: 0 2px 4px rgba(98, 91, 113, 0.2);
}

.button-error {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.button-error:hover {
    box-shadow: 0 2px 8px rgba(186, 26, 26, 0.3);
}

.button:disabled {
    background-color: var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-outline);
    cursor: not-allowed;
    box-shadow: none;
}

.button:disabled::before {
    display: none;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.recording-controls {
    display: flex;
    gap: 12px;
}

.post-recording-controls {
    display: flex;
    gap: 12px;
    opacity: 0;
    transition: opacity var(--duration-medium) ease;
}

.post-recording-controls.visible {
    opacity: 1;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--duration-short) ease;
}

.status-recording {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.status-idle {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
}

.pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

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

.help-text {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    max-width: 400px;
    line-height: 1.4;
    margin-top: 8px;
}

.app-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
}

.info-value {
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-on-surface);
}

.privacy-notice {
    background-color: var(--md-sys-color-surface-container-low);
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--md-sys-color-primary);
    font-size: 12px;
    line-height: 1.4;
    color: var(--md-sys-color-on-surface-variant);
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    left: 20px;
    max-width: 400px;
    margin: 0 auto;
    padding: 16px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transform: translateY(-100px);
    opacity: 0;
    transition: all var(--duration-medium) ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.error {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.notification.warning {
    background-color: rgba(255, 152, 0, 0.1);
    color: var(--md-sys-color-warning);
    border: 1px solid var(--md-sys-color-warning);
}

.notification.success {
    background-color: rgba(15, 157, 88, 0.1);
    color: var(--md-sys-color-success);
    border: 1px solid var(--md-sys-color-success);
}

.notification.info {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--md-sys-color-outline-variant);
    border-top: 4px solid var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--md-sys-color-on-background);
    margin-top: 16px;
    font-weight: 500;
}

/* Responsive design */
@media (max-width: 600px) {
    .container {
        padding: 0 8px;
    }
    
    .recording-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .post-recording-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .button {
        width: 100%;
        justify-content: center;
    }
    
    .permissions-grid {
        grid-template-columns: 1fr;
    }
    
    .data-display {
        grid-template-columns: 1fr;
    }
    
    .notification {
        left: 10px;
        right: 10px;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--md-sys-color-outline);
    }
    
    .permission-item,
    .data-group {
        border: 2px solid var(--md-sys-color-outline);
    }
    
    .button {
        border: 2px solid currentColor;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --md-sys-color-primary: #D0BCFF;
        --md-sys-color-on-primary: #381E72;
        --md-sys-color-primary-container: #4F378B;
        --md-sys-color-on-primary-container: #EADDFF;
        --md-sys-color-secondary: #CCC2DC;
        --md-sys-color-on-secondary: #332D41;
        --md-sys-color-secondary-container: #4A4458;
        --md-sys-color-on-secondary-container: #E8DEF8;
        --md-sys-color-tertiary: #EFB8C8;
        --md-sys-color-on-tertiary: #492532;
        --md-sys-color-tertiary-container: #633B48;
        --md-sys-color-on-tertiary-container: #FFD8E4;
        --md-sys-color-error: #FFB4AB;
        --md-sys-color-on-error: #690005;
        --md-sys-color-error-container: #93000A;
        --md-sys-color-on-error-container: #FFDAD6;
        --md-sys-color-background: #10081D;
        --md-sys-color-on-background: #E6E0E9;
        --md-sys-color-surface: #10081D;
        --md-sys-color-on-surface: #E6E0E9;
        --md-sys-color-surface-variant: #49454F;
        --md-sys-color-on-surface-variant: #CAC4D0;
        --md-sys-color-outline: #938F99;
        --md-sys-color-outline-variant: #49454F;
        --md-sys-color-surface-container-low: #1D1B20;
        --md-sys-color-surface-container: #211F26;
        --md-sys-color-surface-container-high: #2B2930;
        --md-sys-color-inverse-surface: #E6E0E9;
        --md-sys-color-inverse-on-surface: #322F35;
    }
}

/* Circular Record Button */
.record-button-container {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 1000 !important;
    width: 80px;
    height: 80px;
}

.circular-record-button {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    border: none !important;
    background: #DC2626 !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
    font-size: 32px !important;
    position: relative !important;
    outline: none !important;
}

.circular-record-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.15);
}

.circular-record-button:active {
    transform: scale(0.95);
}

.circular-record-button.recording {
    background: #B91C1C;
    animation: record-pulse 1.5s infinite ease-in-out;
}

.circular-record-button .material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal !important;
    font-style: normal !important;
    font-size: 32px !important;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    display: inline-block !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    direction: ltr !important;
    color: white !important;
}

.circular-record-button.recording .material-icons {
    transform: scale(0.8);
}

@keyframes record-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(220, 38, 38, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(220, 38, 38, 0);
    }
}
