/* ===========================================
   Living Water University - Responsive Design
   Universal CSS for all screen sizes
   =========================================== */

/* CSS Variables for consistent theming */
:root {
    --primary-color: #1e40af;
    --primary-hover: #1e3a8a;
    --secondary-color: #6b7280;
    --success-color: #065f46;
    --error-color: #991b1b;
    --warning-color: #d97706;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container System */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-sm {
    max-width: 900px;
}

.container-lg {
    max-width: 1600px;
}

/* Header Responsive */
.header {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 0.25rem;
}

/* Navigation Responsive */
.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 0;
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Main Content Responsive */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.page-title {
    text-align: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.page-title p {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Card System Responsive */
.card {
    background: var(--card-background);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
}

/* Grid System */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Form Elements Responsive */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-background);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Button System Responsive */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #7f1d1d;
}

.btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-full {
    width: 100%;
}

/* Table Responsive */
.table-container {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Desktop Table View */
.table-desktop {
    display: block;
    overflow-x: auto;
}

.table-desktop table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.table-desktop thead {
    background: #f9fafb;
}

.table-desktop th, 
.table-desktop td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-desktop th {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
}

.table-desktop td {
    font-size: 0.9375rem;
}

.table-desktop tr:hover {
    background: #f9fafb;
}

/* Mobile Card View */
.table-mobile {
    display: none;
}

.log-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.log-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.log-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.log-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0;
}

.log-card-badge {
    margin-left: 0.5rem;
}

.log-card-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.log-card-field {
    display: flex;
    flex-direction: column;
}

.log-card-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.log-card-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-word;
}

.log-card-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.log-card-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Statistics Cards Responsive */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 600;
}

.stat-card .number {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--primary-color);
}

/* Search Section Responsive */
.search-section {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-select {
    min-width: 150px;
}

/* Upload Area Responsive */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: clamp(2rem, 5vw, 3rem) clamp(1rem, 3vw, 2rem);
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: #f9fafb;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #dbeafe;
    border-style: solid;
}

.upload-icon {
    width: clamp(48px, 8vw, 64px);
    height: clamp(48px, 8vw, 64px);
    margin: 0 auto 1.5rem;
    color: var(--primary-color);
}

.upload-text {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* File Preview Responsive */
.file-preview {
    display: none;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.file-preview.show {
    display: block;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
}

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

.file-details {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #dbeafe;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: 600;
    flex-shrink: 0;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}

.file-size {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Badge System */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-primary {
    background: #dbeafe;
    color: var(--primary-color);
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning-color);
}

.badge-success {
    background: #d1fae5;
    color: var(--success-color);
}

.badge-error {
    background: #fee2e2;
    color: var(--error-color);
}

/* Message System */
.message {
    display: none;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1.5rem;
    font-size: 0.9375rem;
}

.message.show {
    display: block;
}

.message-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: var(--success-color);
}

.message-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: var(--error-color);
}

/* Loading Spinner */
.loading {
    display: none;
    text-align: center;
    padding: 2rem;
}

.loading.show {
    display: block;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer Responsive */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .nav-links {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .nav-links a {
        padding: 0.75rem;
        border-radius: var(--border-radius);
        background: #f9fafb;
    }
    
    .nav-links a:hover {
        background: #eff6ff;
    }
    
    .main-content {
        padding: 1rem 0;
    }
    
    .card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .search-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input,
    .search-select {
        min-width: auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .file-details {
        justify-content: center;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Switch to mobile card view for tables */
    .table-desktop {
        display: none;
    }
    
    .table-mobile {
        display: block;
    }
    
    .log-card-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-title h1 {
        font-size: 1.5rem;
    }
    
    .page-title p {
        font-size: 0.9375rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .upload-area {
        padding: 1.5rem 0.75rem;
    }
    
    .upload-text {
        font-size: 1rem;
    }
    
    .upload-subtext {
        font-size: 0.8125rem;
    }
}

/* Large screens optimization */
@media (min-width: 1400px) {
    .container {
        padding: 0 2rem;
    }
    
    .main-content {
        padding: 3rem 0;
    }
    
    .card {
        padding: 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .container {
        max-width: 1800px;
    }
    
    .page-title h1 {
        font-size: 3rem;
    }
    
    .page-title p {
        font-size: 1.5rem;
    }
}

/* Print styles */
@media print {
    .header,
    .footer,
    .btn,
    .nav-links {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    body {
        background: white;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    .card {
        border: 2px solid #000000;
    }
}

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