/**
 * Responsive Base CSS Framework
 * Mobile-first responsive design utilities
 * Version: 1.0.0
 */

/* ========================================
   RESET & BASE STYLES
   ======================================== */

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

/* ========================================
   CONTAINER
   ======================================== */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 769px) {
    .container {
        padding: 0 24px;
    }
}

@media (min-width: 1025px) {
    .container {
        padding: 0 32px;
    }
}

/* ========================================
   RESPONSIVE GRID SYSTEM
   ======================================== */

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

@media (min-width: 769px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1025px) {
    .grid {
        gap: 24px;
    }
}

/* Flexbox utilities */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

.flex-center {
    justify-content: center;
    align-items: center;
}

.flex-between {
    justify-content: space-between;
    align-items: center;
}

.gap-8 {
    gap: 8px;
}

.gap-16 {
    gap: 16px;
}

.gap-24 {
    gap: 24px;
}

/* ========================================
   TOUCH-FRIENDLY BUTTONS
   ======================================== */

.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    touch-action: manipulation;
    transition: background-color 0.2s, transform 0.1s;
    line-height: 1.2;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #007bff;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #545b62;
}

.btn-success {
    background-color: #28a745;
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background-color: #218838;
}

.btn-danger {
    background-color: #dc3545;
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
}

.btn-warning {
    background-color: #ffc107;
    color: #000;
}

.btn-warning:hover:not(:disabled) {
    background-color: #e0a800;
}

@media (max-width: 480px) {
    .btn-full-mobile {
        width: 100%;
        display: block;
    }
}

/* ========================================
   RESPONSIVE TABLES
   ======================================== */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

table {
    min-width: 600px;
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

table th {
    font-weight: 600;
    background-color: #f8f9fa;
}

@media (max-width: 768px) {
    table th,
    table td {
        padding: 8px;
        font-size: 14px;
    }
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */

h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin: 0 0 1rem 0;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.25rem, 4vw, 2rem);
    margin: 0 0 0.875rem 0;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    margin: 0 0 0.75rem 0;
    font-weight: 600;
    line-height: 1.4;
}

p {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    p {
        font-size: 14px;
    }
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

@media (min-width: 769px) {
    .card {
        padding: 24px;
    }
}

.card-header {
    margin: -16px -16px 16px -16px;
    padding: 16px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

@media (min-width: 769px) {
    .card-header {
        margin: -24px -24px 24px -24px;
        padding: 16px 24px;
    }
}

/* ========================================
   SPACING UTILITIES
   ======================================== */

.m-0 { margin: 0; }
.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-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

/* ========================================
   VISIBILITY UTILITIES
   ======================================== */

@media (max-width: 768px) {
    .hide-tablet {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* ========================================
   TEXT UTILITIES
   ======================================== */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: #6c757d;
}

.text-primary {
    color: #007bff;
}

.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

.text-warning {
    color: #ffc107;
}

/* ========================================
   RESPONSIVE IMAGES
   ======================================== */

img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   LOADING STATES
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.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;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .btn {
        display: none;
    }
}


/* Dashboard Styles */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    margin: 0;
    color: #4F46E5;
    font-size: 2rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username {
    font-weight: 500;
    color: #374151;
}

.org-badge {
    padding: 0.5rem 1rem;
    background: #EEF2FF;
    border-radius: 0.5rem;
    color: #4338CA;
    font-size: 0.875rem;
    font-weight: 500;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.action-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.action-card .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.action-card h3 {
    margin: 0 0 0.5rem 0;
    color: #374151;
    font-size: 1.25rem;
}

.action-card p {
    margin: 0;
    color: #6B7280;
    font-size: 0.875rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 1rem;
    }
    
    .header {
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .quick-actions-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .action-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .dashboard-container {
        padding: 0.5rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .action-card {
        padding: 1.25rem;
    }
    
    .action-card .icon {
        font-size: 2.5rem;
    }
}
