/**
 * Responsive Styles for Lifting Master Modules
 * Mobile-first approach with progressive enhancement
 */

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

:root {
    --primary: #003366;
    --accent: #ffcc00;
    --text-dark: #1a1a1a;
    --text-light: #666;
    --bg-light: #f8f9fa;
    --border-color: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 15px;
    font-family: '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;
}

h2 {
    font-size: 1.5rem;
    margin: 1.5rem 0 1rem 0;
    color: var(--primary);
    line-height: 1.3;
}

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

p {
    margin: 0 0 1rem 0;
}

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

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

.content-wrapper {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.section {
    margin-bottom: 1.5rem;
}

.section-header {
    background: linear-gradient(135deg, var(--primary) 0%, #001a33 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.section-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ==========================================
   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;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 16px; /* Prevents zoom on iOS */
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    transition: all 0.2s;
    -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-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 51, 102, 0.3);
}

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

.btn-secondary:hover,
.btn-secondary:active {
    background: #e6b800;
    transform: translateY(-2px);
}

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

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

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

.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;
}

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

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

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    white-space: nowrap;
}

tr:hover {
    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: 8px;
        overflow: hidden;
    }
    
    .table-responsive td {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem;
        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: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.card-header {
    margin: -1rem -1rem 1rem -1rem;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
}

.card-body {
    padding: 0;
}

.card-footer {
    margin: 1rem -1rem -1rem -1rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 0 0 12px 12px;
}

/* ==========================================
   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;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

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

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

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

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

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

.result-box {
    background: linear-gradient(135deg, var(--primary) 0%, #001a33 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    margin: 1rem 0;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.result-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================
   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 1s linear infinite;
    margin: 0 auto;
}

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

/* ==========================================
   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); }

.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; }

/* ==========================================
   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;
    }
}

/* ==========================================
   DARK MODE SUPPORT (Optional)
   ========================================== */

@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode
    :root {
        --text-dark: #e5e7eb;
        --text-light: #9ca3af;
        --bg-light: #1f2937;
        --border-color: #374151;
    }
    
    body {
        background: #111827;
        color: var(--text-dark);
    }
    
    .content-wrapper,
    .card {
        background: #1f2937;
    }
    
    input,
    select,
    textarea {
        background: #374151;
        color: white;
        border-color: #4b5563;
    }
    */
}

/* ==========================================
   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;
}
