:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: var(--dark-color);
    display: flex;
    flex-direction: column;
}

/* Navbar Styles */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
}

.navbar-brand {
    font-size: 1.5rem;
    transition: transform 0.2s;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.nav-link {
    font-weight: 500;
    transition: all 0.3s;
    border-radius: 6px;
    margin: 0 4px;
    padding: 8px 16px !important;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0 1rem 0;
    position: relative;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: all 0.3s ease;
    border: none;
    box-shadow: var(--shadow-sm);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, var(--success-color) 100%);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

/* Tables */
.table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.table thead th {
    border: none;
    padding: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: all 0.2s;
}

.table tbody tr:hover {
    background-color: var(--light-color);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    transition: all 0.3s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
}

.alert-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

.alert-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 4rem 0;
    border-radius: 0 0 50px 50px;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-lg);
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-section .lead {
    font-size: 1.25rem;
    opacity: 0.95;
}

/* Stats Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s;
    border-left: 4px solid var(--primary-color);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
}

.stat-card .stat-label {
    color: #6b7280;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Audio Player */
audio {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

/* Badges */
.badge {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 0.5rem 0;
    position: relative;
    background-color: rgba(248, 249, 250, 0.8);
    border-top: 1px solid var(--border-color);
    z-index: 10;
}

.footer p {
    font-size: 0.75rem;
    margin: 0;
    padding: 0.25rem 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
    /* Hero Section */
    .hero-section {
        padding: 2rem 0;
        border-radius: 0 0 30px 30px;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    .hero-section .lead {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Buttons */
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Tables - Convert to cards on mobile */
    .table-responsive {
        border-radius: 12px;
        overflow: hidden;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border-radius: 12px;
        box-shadow: var(--shadow-md);
        padding: 1rem;
    }
    
    .table tbody td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .table tbody td:last-child {
        border-bottom: none;
    }
    
    .table tbody td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--primary-color);
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Touch targets - minimum 44x44px */
    .btn, .nav-link, a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better touch feedback */
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Prevent text selection on buttons */
    .btn {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    
    /* Stat Cards */
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .stat-card .stat-icon {
        font-size: 2rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    /* Navbar */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    /* Container padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Main content */
    .main-content {
        padding: 1rem 0 4rem 0;
    }
    
    /* Footer */
    .footer {
        padding: 0.4rem 0;
        text-align: center;
    }
    
    .footer p {
        font-size: 0.7rem;
    }
    
    /* Details page */
    .card-body .row.g-3 > div {
        margin-bottom: 1rem;
    }
    
    /* Audio player */
    audio {
        width: 100%;
    }
    
    /* Badges */
    .badge {
        display: inline-block;
        margin: 0.25rem;
    }
    
    /* Flex gaps */
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }
    
    /* Button groups */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group-mobile .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Navbar mobile */
    .navbar-collapse {
        margin-top: 1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem !important;
        margin: 0.25rem 0;
    }
    
    /* Recording buttons stack on mobile */
    #recordingSection .d-flex {
        flex-direction: column;
    }
    
    #recordingSection .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Audio preview full width */
    #audioPreview {
        width: 100%;
    }
    
    /* Card headers smaller on mobile */
    .card-header h4 {
        font-size: 1.1rem;
    }
    
    /* Hide some icons on very small screens */
    @media (max-width: 400px) {
        .bi {
            margin-right: 0.25rem !important;
        }
        
        .navbar-brand .bi {
            display: none;
        }
    }
}

@media (max-width: 576px) {
    /* Extra small devices */
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section .lead {
        font-size: 0.875rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h4 {
        font-size: 1.25rem;
    }
    
    h5 {
        font-size: 1.1rem;
    }
    
    .btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .p-4 {
        padding: 1rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-5 {
        margin-bottom: 2rem !important;
    }
}

/* Focus styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}
