/* Global Responsive Design for SmartCalcs */
/* Mobile-first approach with progressive enhancement */

/* ===== GLOBAL RESPONSIVE VARIABLES ===== */
:root {
    /* Responsive breakpoints */
    --mobile-max: 768px;
    --tablet-min: 769px;
    --tablet-max: 1024px;
    --desktop-min: 1025px;
    
    /* Color variables */
    --primary-color: #6366f1;
    --primary-hover: #5b56f0;
    --secondary-color: #f8fafc;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark: #1f2937;
    --light: #f9fafb;
    --border-color: #e5e7eb;
    
    /* Responsive spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Responsive typography */
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-xxl: 24px;
    --font-size-xxxl: 32px;
    
    /* Mobile touch targets */
    --touch-target: 44px;
    --touch-target-lg: 56px;
}

/* ===== GLOBAL RESPONSIVE CONTAINER ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
}

/* ===== RESPONSIVE GRID SYSTEM ===== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -var(--spacing-sm);
}

.col {
    flex: 1;
    padding: 0 var(--spacing-sm);
    min-width: 0;
}

.col-12 { flex: 0 0 100%; }
.col-6 { flex: 0 0 50%; }
.col-4 { flex: 0 0 33.333333%; }
.col-3 { flex: 0 0 25%; }

@media (max-width: 768px) {
    .col-6, .col-4, .col-3 {
        flex: 0 0 100%;
    }
    
    .mobile-col-6 { flex: 0 0 50%; }
}

/* ===== NAVIGATION RESPONSIVE ===== */
.navbar {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
}

.nav-logo {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

/* Mobile Navigation */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    cursor: pointer;
    padding: var(--spacing-sm);
    color: var(--dark);
}

/* Dropdown Navigation */
.dropdown {
    position: relative;
}

.dropdown-toggle::after {
    content: '';
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    list-style: none;
    margin: 0;
    padding: var(--spacing-sm) 0;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu li {
    padding: 0;
}

.dropdown-menu a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--dark);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 0 var(--spacing-sm);
}

.dropdown-menu a:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--spacing-lg);
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-link {
        width: 100%;
        padding: var(--spacing-md);
        text-align: center;
        font-size: var(--font-size-lg);
        border-radius: 12px;
    }
    
    /* Mobile Dropdown Styles */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 0;
        margin-left: var(--spacing-lg);
        margin-top: var(--spacing-sm);
    }
    
    .dropdown-menu a {
        padding: var(--spacing-sm) 0;
        margin: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        color: #6b7280;
        font-size: var(--font-size-base);
    }
    
    .dropdown-menu a:hover {
        background: transparent;
        color: var(--primary-color);
    }
    
    .dropdown-toggle::after {
        display: none;
    }
}

/* ===== FORM ELEMENTS RESPONSIVE ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--dark);
    font-size: var(--font-size-sm);
}

.form-control, 
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--spacing-md);
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: var(--font-size-base);
    font-family: inherit;
    background: #ffffff;
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-height: var(--touch-target);
}

@media (max-width: 768px) {
    .form-control, 
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        padding: var(--spacing-lg);
        font-size: var(--font-size-lg);
        min-height: var(--touch-target-lg);
        border-radius: 16px;
    }
}

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

/* ===== BUTTON RESPONSIVE ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md) var(--spacing-xl);
    border: none;
    border-radius: 12px;
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-height: var(--touch-target);
    gap: var(--spacing-sm);
}

@media (max-width: 768px) {
    .btn {
        padding: var(--spacing-lg) var(--spacing-xl);
        font-size: var(--font-size-lg);
        min-height: var(--touch-target-lg);
        border-radius: 16px;
        width: 100%;
        margin-bottom: var(--spacing-md);
    }
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: #f8fafc;
    color: var(--dark);
    border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: var(--primary-color);
}

/* ===== CARD RESPONSIVE ===== */
.card {
    background: white;
    border-radius: 16px;
    padding: var(--spacing-xl);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: var(--spacing-lg);
}

@media (max-width: 768px) {
    .card {
        padding: var(--spacing-lg);
        border-radius: 12px;
        margin-bottom: var(--spacing-md);
    }
}

.card-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

@media (max-width: 768px) {
    .card-title {
        font-size: var(--font-size-lg);
    }
}

/* ===== TABLE RESPONSIVE ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-lg);
}

th, td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

@media (max-width: 768px) {
    th, td {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    /* Stack table on mobile */
    .mobile-stack table,
    .mobile-stack thead,
    .mobile-stack tbody,
    .mobile-stack th,
    .mobile-stack td,
    .mobile-stack tr {
        display: block;
    }
    
    .mobile-stack thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .mobile-stack tr {
        border: 1px solid #ccc;
        margin-bottom: var(--spacing-md);
        border-radius: 8px;
        padding: var(--spacing-sm);
    }
    
    .mobile-stack td {
        border: none;
        position: relative;
        padding-left: 50%;
    }
    
    .mobile-stack td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: var(--spacing-sm);
        white-space: nowrap;
        font-weight: 600;
    }
}

/* ===== MODAL RESPONSIVE ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: var(--spacing-lg);
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal {
        padding: var(--spacing-md);
    }
    
    .modal-content {
        padding: var(--spacing-lg);
        border-radius: 12px;
        max-height: 95vh;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.d-block { display: block; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-none { display: none; }

@media (max-width: 768px) {
    .mobile-text-center { text-align: center; }
    .mobile-d-block { display: block; }
    .mobile-d-none { display: none; }
    .mobile-full-width { width: 100%; }
}

@media (min-width: 769px) {
    .desktop-d-flex { display: flex; }
    .desktop-d-none { display: none; }
}

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

/* ===== RESPONSIVE IMAGES ===== */
img {
    max-width: 100%;
    height: auto;
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== SAFE AREA SUPPORT FOR MOBILE ===== */
@supports (padding: max(0px)) {
    .safe-area-padding {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
}

/* ===== FOCUS MANAGEMENT ===== */
.focus-visible:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== RESPONSIVE CHARTS AND CANVAS ===== */
.chart-container {
    position: relative;
    width: 100%;
    height: 400px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
    }
}

canvas {
    max-width: 100%;
    height: auto;
}