/**
 * Responsive Styles for Lifting Master Modules
 * Mobile-first approach with progressive enhancement
 * Version 3.0 — Premium Redesign
 */

/* ==========================================
   GOOGLE FONTS (fallback if styles.css not loaded)
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ==========================================
   MOBILE-FIRST BASE STYLES
   ========================================== */

:root {
    --primary: #003366;
    --primary-dark: #002244;
    --primary-light: #004d99;
    --accent: #ffcc00;
    --accent-hover: #e6b800;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --bg-light: #f8fafc;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px -4px rgba(0,0,0,0.1), 0 8px 16px -8px rgba(0,0,0,0.06);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 15px;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   TYPOGRAPHY - RESPONSIVE
   ========================================== */

h1 {
    font-size: 1.75rem;
    margin: 0 0 1rem 0;
    color: var(--primary);
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    margin: 1.5rem 0 1rem 0;
    color: var(--primary);
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.25rem;
    margin: 1rem 0 0.75rem 0;
    color: var(--primary);
    font-weight: 700;
}

p {
    margin: 0 0 1rem 0;
    line-height: 1.7;
}

/* ==========================================
   CONTAINERS - RESPONSIVE
   ========================================== */

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.content-wrapper {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition-base);
}

.content-wrapper:hover {
    box-shadow: var(--shadow-lg);
}

.section {
    margin-bottom: 1.5rem;
}

.section-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.section-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ==========================================
   FORMS - MOBILE OPTIMIZED
   ========================================== */

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 16px; /* Prevents zoom on iOS */
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-dark);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* ==========================================
   BUTTONS - TOUCH FRIENDLY
   ========================================== */

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--transition-fast), box-shadow var(--transition-base), background var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 51, 102, 0.25);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: var(--primary);
    font-weight: 700;
}

.btn-secondary:hover,
.btn-secondary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 204, 0, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

.btn-block {
    width: 100%;
    display: flex;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.btn-group .btn {
    flex: 1;
    min-width: 120px;
}

/* ==========================================
   TABLES - RESPONSIVE
   ========================================== */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9rem;
}

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

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-light);
}

/* Mobile table - stack on small screens */
@media (max-width: 640px) {
    .table-responsive {
        display: block;
    }
    
    .table-responsive thead {
        display: none;
    }
    
    .table-responsive tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        overflow: hidden;
        box-shadow: var(--shadow-sm);
    }
    
    .table-responsive td {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        border: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .table-responsive td:last-child {
        border-bottom: none;
    }
    
    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary);
    }
}

/* ==========================================
   CARDS - RESPONSIVE
   ========================================== */

.card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    margin: -1rem -1rem 1rem -1rem;
    padding: 1rem 1.25rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 700;
    font-size: 0.95rem;
}

.card-body {
    padding: 0;
}

.card-footer {
    margin: 1rem -1rem -1rem -1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   GRID SYSTEM - RESPONSIVE
   ========================================== */

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

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

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

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

/* ==========================================
   ALERTS & MESSAGES
   ========================================== */

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    border-left: 4px solid;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert-success {
    background: var(--success-bg, #d1fae5);
    border-color: var(--success);
    color: #065f46;
}

.alert-warning {
    background: var(--warning-bg, #fef3c7);
    border-color: var(--warning);
    color: #92400e;
}

.alert-danger {
    background: var(--danger-bg, #fee2e2);
    border-color: var(--danger);
    color: #991b1b;
}

.alert-info {
    background: var(--info-bg, #dbeafe);
    border-color: var(--info);
    color: #1e40af;
}

/* ==========================================
   RESULT DISPLAYS
   ========================================== */

.result-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin: 1rem 0;
    box-shadow: 0 8px 25px rgba(0, 51, 102, 0.2);
    position: relative;
    overflow: hidden;
}

.result-box::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 204, 0, 0.08);
    border-radius: 50%;
    pointer-events: none;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0.5rem 0;
    letter-spacing: -0.02em;
}

.result-label {
    font-size: 0.85rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* ==========================================
   LOADING & SPINNERS
   ========================================== */

.loading {
    text-align: center;
    padding: 2rem;
}

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

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

/* ==========================================
   BADGES & TAGS
   ========================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #d1fae5; color: #059669; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger  { background: #fee2e2; color: #dc2626; }

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden { display: none; }
.visible { display: block; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-light); }

.bg-primary { background: var(--primary); color: white; }
.bg-success { background: var(--success); color: white; }
.bg-danger { background: var(--danger); color: white; }
.bg-warning { background: var(--warning); color: white; }

.rounded { border-radius: var(--radius-md); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .no-print {
        display: none !important;
    }
    
    .content-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    button, .btn {
        display: none;
    }
    
    @page {
        margin: 1cm;
    }
}

/* ==========================================
   TABLET BREAKPOINT (640px+)
   ========================================== */

@media (min-width: 640px) {
    body {
        padding: 20px;
    }
    
    h1 {
        font-size: 2.25rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    .content-wrapper {
        padding: 1.5rem;
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .btn-group .btn {
        flex: 0 1 auto;
    }
}

/* ==========================================
   DESKTOP BREAKPOINT (768px+)
   ========================================== */

@media (min-width: 768px) {
    body {
        padding: 30px;
    }
    
    .container {
        max-width: 1200px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .content-wrapper {
        padding: 2rem;
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   LARGE DESKTOP (1024px+)
   ========================================== */

@media (min-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .section-header {
        padding: 1.5rem;
    }
}

/* ==========================================
   TOUCH DEVICE OPTIMIZATIONS
   ========================================== */

@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button,
    .btn,
    a {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }
    
    /* Larger form inputs */
    input,
    select,
    textarea {
        font-size: 16px;
        padding: 1rem;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

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

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
