:root {
    /* Brand Colors (Common to both) */
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #6366f1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Light Theme Palette (Default) */
    --bg-deep: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-header: #ffffff;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-blur: blur(12px);

    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --transition: all 0.3s ease;
}

/* Dark Theme Overrides */
body.dark-theme {
    --bg-deep: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-header: #1e293b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --border-color: rgba(255, 255, 255, 0.1);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.15) 0, transparent 50%);
    background-attachment: fixed;
    transition: var(--transition);
    /* Mobile improvements */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent double tap zoom on buttons */
button, a, input, select, textarea {
    -webkit-touch-callout: none;
}

/* Improve input styling on mobile */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="password"],
textarea,
select {
    font-size: 16px;
    border-radius: 8px;
}

/* Prevent iOS zoom on input focus */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
}

/* ===== UTILITY CLASSES ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

/* ===== API KEY NOTICE ===== */
.api-notice {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 1.25rem;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
}

.api-notice-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.api-notice h3 {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
    font-weight: bold;
}

.api-notice p {
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.api-input-group {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    align-items: center;
}

.api-input-group input {
    flex: 1;
    min-width: 300px;
    padding: 0.625rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.api-notice-footer {
    margin-top: 0.625rem;
    margin-bottom: 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

.btn-close {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== HEADER ===== */
.header {
    background: var(--bg-header);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Navigation Buttons */
.nav-btn {
    transition: all 0.3s ease;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

/* Home button specific styling */
a.nav-btn:hover {
    background: linear-gradient(135deg, #764ba2, #667eea) !important;
    border-color: rgba(118, 75, 162, 0.6) !important;
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.4);
}

/* Dashboard button hover */
button.nav-btn:nth-of-type(1):hover {
    background: rgba(59, 130, 246, 0.3) !important;
    border-color: rgba(59, 130, 246, 0.7) !important;
    color: #3b82f6 !important;
}

/* Workflows button hover */
button.nav-btn:nth-of-type(2):hover {
    background: rgba(139, 92, 246, 0.3) !important;
    border-color: rgba(139, 92, 246, 0.7) !important;
    color: #8b5cf6 !important;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--primary-glow);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-icon {
    background: transparent;
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--glass-border);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Report Badge */
.report-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ===== FORM ELEMENTS ===== */
.breadcrumb {
    margin-bottom: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.select-input,
.input {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    transition: var(--transition);
}

.select-input:focus,
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    outline: none;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    transform: translateY(-5px);
}

.card-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== GRID ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-header);
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

.footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.footer a:hover {
    color: #60a5fa;
    text-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

.footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
}

.footer a:hover::after {
    width: 100%;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== MODULE CARDS ===== */
.module-card {
    cursor: pointer;
    text-align: center;
    padding: 2rem;
}

.module-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ===== CALCULATOR FORMS ===== */
.calculator-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.result-box {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid var(--primary-glow);
    border-left: 4px solid var(--primary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin-top: 2rem;
}

.result-title {
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== DASHBOARD ===== */
.dashboard-header {
    text-align: center;
    padding: 2rem 0 3rem;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.dashboard-header p {
    font-size: 1.125rem;
    color: var(--text-muted);
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.module-card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition);
}

.module-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

/* Workflow Cards */
.workflow-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px -10px rgba(59, 130, 246, 0.4), 0 10px 20px -5px rgba(139, 92, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.6) !important;
}

.module-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.module-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.badge {
    padding: 0.25rem 0.875rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-secondary {
    background: var(--secondary);
}

.badge-success {
    background: var(--success);
}

/* ===== MODULE PAGE ===== */
.module-page-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.module-page-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.module-page-header .text-muted {
    color: rgba(255, 255, 255, 0.9);
}

.calculators-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.calculator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calculator-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateX(4px);
}

.calculator-item.coming-soon {
    opacity: 0.6;
    cursor: not-allowed;
}

.calculator-item.coming-soon:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}

.calculator-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calculator-info h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.calculator-arrow {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: bold;
}

/* ===== COMING SOON ===== */
.coming-soon-box {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
}

.coming-soon-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.coming-soon-box h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.coming-soon-box p {
    margin-bottom: 0.5rem;
}

.coming-soon-box .btn {
    margin-top: 1.5rem;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Mobile Menu Dropdown */
.main-nav.mobile-open {
    display: flex !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-surface);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    gap: 0.75rem !important;
}

/* Mobile Sidebar Toggle for Console */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 80px;
    left: 10px;
    z-index: 200;
    background: var(--primary);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

/* Visual Builder Toggle Buttons */
.builder-toggle {
    transition: var(--transition);
}

.builder-toggle:hover {
    transform: scale(1.1);
}

.builder-toggle:active {
    transform: scale(0.95);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Extra Small Devices (Phones, 320px to 479px) */
@media (max-width: 479px) {
    html {
        font-size: 14px;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 0.75rem;
    }

    .header {
        padding: 0.5rem 0;
    }

    .header-content {
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.1rem;
        min-width: auto;
    }

    .main-nav {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: flex !important;
        font-size: 1.25rem;
    }

    .header-controls {
        gap: 0.4rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .header-controls button,
    .header-controls select {
        min-width: 40px;
        min-height: 40px;
    }

    .select-input {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-height: 40px;
    }

    .btn-sm {
        padding: 0.35rem 0.5rem;
        font-size: 0.65rem;
        min-height: 36px;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .dashboard-header {
        text-align: center;
        padding: 1rem 0.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .dashboard-header p {
        font-size: 0.8rem;
    }

    .modules-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .module-card {
        padding: 1rem;
        border-radius: 8px;
    }

    .module-card h3 {
        font-size: 0.95rem;
    }

    .module-icon {
        font-size: 1.75rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .card h3 {
        font-size: 0.95rem;
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .modal-header h2 {
        font-size: 1.1rem;
        margin: 0;
    }

    .modal-body {
        padding: 15px;
        font-size: 0.9rem;
    }

    .floating-nav {
        bottom: 0.5rem;
        right: 0.5rem;
    }

    .fab-main {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }

    .fab-option {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    .workspace {
        padding: 0.75rem 0;
    }

    .workspace-content {
        padding: 0 0.5rem;
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }

    .input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.6rem;
    }

    .result-box {
        padding: 0.75rem;
        border-radius: 6px;
        font-size: 0.9rem;
    }

    .breadcrumb {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        margin-bottom: 1rem;
        gap: 0.3rem;
    }
}

/* Small Devices (Phones, 480px to 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 0 0.75rem;
    }

    .header {
        padding: 0.6rem 0;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .logo {
        font-size: 1.3rem;
    }

    .main-nav {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: flex !important;
        font-size: 1.35rem;
    }

    .header-controls {
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: 100%;
    }

    .header-controls button,
    .header-controls select {
        min-height: 40px;
    }

    .select-input {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .btn {
        padding: 0.55rem 0.9rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .btn-sm {
        padding: 0.4rem 0.7rem;
        font-size: 0.7rem;
    }

    .dashboard-header {
        padding: 1.25rem 0.75rem;
        text-align: center;
    }

    .dashboard-header h1 {
        font-size: 1.8rem;
        margin-bottom: 0.75rem;
    }

    .dashboard-header p {
        font-size: 0.9rem;
    }

    .modules-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .module-card {
        padding: 1.25rem;
        border-radius: 10px;
    }

    .module-card h3 {
        font-size: 1rem;
    }

    .module-icon {
        font-size: 2rem;
    }

    .card {
        padding: 1rem;
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }

    .modal-header {
        padding: 15px;
        font-size: 0.95rem;
    }

    .modal-body {
        padding: 20px;
    }

    .floating-nav {
        bottom: 1rem;
        right: 1rem;
    }

    .fab-main {
        width: 55px;
        height: 55px;
        font-size: 1.25rem;
    }

    .fab-option {
        width: 45px;
        height: 45px;
        font-size: 1.05rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .input {
        font-size: 16px;
        padding: 0.6rem;
    }

    .result-box {
        padding: 1rem;
        font-size: 0.95rem;
    }

    .breadcrumb {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        margin-bottom: 1.25rem;
    }
}

/* Tablets (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 0 1rem;
    }

    .header-content {
        gap: 1rem;
    }

    .logo {
        font-size: 1.4rem;
    }

    .main-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }

    .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-height: 40px;
    }

    .header-controls {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .dashboard-header {
        padding: 2rem 1rem;
    }

    .dashboard-header h1 {
        font-size: 2.2rem;
    }

    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .module-card {
        padding: 1.5rem;
    }

    .workspace-content {
        max-width: 100%;
        padding: 0 1.5rem;
    }

    .sidebar-scaffold {
        width: 280px;
        min-width: 280px;
    }

    .card {
        padding: 1.25rem;
    }

    .modal-content {
        max-width: 85vw;
    }

    .floating-nav {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .breadcrumb {
        margin-bottom: 1.5rem;
    }
}

/* Mobile and Tablet Common (up to 1023px) */
@media (max-width: 1023px) {
    .header-content {
        flex-wrap: wrap;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .api-input-group {
        flex-direction: column;
    }

    .api-input-group input {
        min-width: 100%;
        width: 100%;
    }

    .module-page-header {
        flex-direction: column;
        text-align: center;
    }

    /* Console Layout Mobile */
    .sidebar-scaffold {
        position: fixed;
        left: -100%;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 999;
        background: var(--bg-surface);
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
        border-right: 1px solid var(--border-color);
    }

    .console-layout.sidebar-open .sidebar-scaffold {
        left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
    }

    .workspace {
        width: 100%;
        padding: 1rem 0;
    }

    .workspace-content {
        padding: 0 1rem;
    }

    /* Visual Builder adjustments */
    .visual-builder-layout {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .builder-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        background: var(--bg-surface);
        border-right: 1px solid var(--border-color);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 1.5rem 1rem;
    }

    .builder-sidebar.open {
        left: 0;
    }

    .builder-properties {
        position: fixed;
        right: -100%;
        top: 0;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        background: var(--bg-surface);
        border-left: 1px solid var(--border-color);
        transition: right 0.3s ease;
        overflow-y: auto;
        padding: 1.5rem 1rem;
    }

    .builder-properties.open {
        right: 0;
    }

    .builder-canvas-container {
        width: 100%;
        min-height: 400px;
        flex: 1;
        touch-action: none;
    }

    /* Visual canvas for workflow builder */
    canvas#visual-canvas {
        display: block;
        width: 100%;
        height: 100%;
        touch-action: none;
        -webkit-user-select: none;
        user-select: none;
        cursor: grab;
    }

    canvas#visual-canvas:active {
        cursor: grabbing;
    }

    .canvas-toolbar {
        top: 12px;
        left: 12px;
        right: auto;
        gap: 6px;
        flex-wrap: wrap;
        max-width: calc(100% - 24px);
    }

    .canvas-toolbar button {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    .canvas-controls {
        bottom: 12px;
        right: 12px;
        left: auto;
        gap: 6px;
        flex-wrap: wrap;
        max-width: calc(100% - 24px);
    }

    .canvas-controls button {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-height: 36px;
    }

    /* Show builder toggle buttons on mobile */
    .builder-toggle {
        display: block !important;
    }

    /* Improved form spacing */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
    }

    .input,
    .select-input {
        width: 100%;
        min-height: 44px;
    }

    /* Calculator cards on mobile */
    .calculator-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Sidebar items on mobile */
    .sidebar-item {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
}

/* Tablets in Landscape and Small Laptops (1024px to 1439px) */
@media (min-width: 1024px) and (max-width: 1439px) {
    .container {
        max-width: 1000px;
    }

    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar-scaffold {
        width: 280px;
        min-width: 280px;
    }

    .workspace-content {
        max-width: 900px;
    }
}

/* Large Screens (1440px and above) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }

    .modules-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .workspace-content {
        max-width: 1200px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .select-input,
    .input,
    .sidebar-item,
    .module-card,
    .calculator-item,
    .fab-option,
    .fab-main {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }

    .btn {
        padding: 0.75rem 1rem;
    }

    .btn-sm {
        padding: 0.6rem 0.85rem;
        min-height: 40px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .input,
    .select-input {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
    }

    .card:hover {
        transform: none;
    }

    .module-card:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }

    .nav-btn:hover {
        transform: none;
    }

    /* Larger touch targets for mobile */
    .sidebar-item {
        padding: 0.85rem;
    }

    .select-input,
    .input {
        font-size: 16px;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    a:hover {
        opacity: 0.9;
    }
}

/* Landscape Orientation on Phones */
@media (max-width: 767px) and (orientation: landscape) {
    html {
        font-size: 13px;
    }

    .header {
        padding: 0.4rem 0;
    }

    .logo {
        font-size: 1rem;
    }

    .header-controls {
        gap: 0.3rem;
    }

    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
        min-height: 36px;
    }

    .dashboard-header {
        padding: 0.75rem 0;
        margin-bottom: 0.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.3rem;
        margin-bottom: 0.25rem;
    }

    .console-layout {
        height: calc(100vh - 60px);
    }

    .sidebar-scaffold {
        height: 100vh;
    }

    .floating-nav {
        bottom: 0.4rem;
        right: 0.4rem;
    }

    .fab-main {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }

    .fab-option {
        width: 38px;
        height: 38px;
        font-size: 0.85rem;
    }

    .modal-content {
        max-height: 85vh;
    }

    .modal-header {
        padding: 10px 12px;
    }

    .modal-body {
        padding: 12px;
        max-height: calc(85vh - 50px);
    }

    .card {
        padding: 0.75rem;
    }

    .form-group {
        margin-bottom: 0.5rem;
    }

    .input {
        font-size: 16px;
        padding: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .floating-nav,
    .sidebar-toggle,
    .mobile-menu-toggle,
    .breadcrumb {
        display: none !important;
    }

    body {
        background: white;
    }

    .card,
    .result-box {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* ===== CONSOLE LAYOUT (2-SCREEN) ===== */
.console-layout {
    display: flex;
    height: calc(100vh - 72px);
    /* Full height minus header */
    overflow: hidden;
    background: var(--bg-deep);
}

.sidebar-scaffold {
    width: 300px;
    min-width: 300px;
    height: 100%;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-search {
    padding: 1rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sidebar-item:hover,
.sidebar-item.active {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.sidebar-item.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Difficulty Level Styling */
.difficulty-group {
    margin-bottom: 1rem;
}

.difficulty-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    letter-spacing: 0.05em;
}

.level-badge {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: var(--transition);
}

.sidebar-item:hover .level-badge {
    opacity: 1;
    transform: scale(1.1);
}

.level-badge.beginner {
    color: var(--success);
}

.level-badge.medium {
    color: var(--warning);
}

.level-badge.advanced {
    color: var(--danger);
}

.workspace {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
}

.workspace-content {
    max-width: 1000px;
    margin: 0 auto;
}

/* ===== CALCULATION DETAILS ===== */
.calculation-details {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

.calculation-details h4 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.logic-step {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
    position: relative;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.logic-step::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
}

code.formula {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    color: var(--success);
}

/* ===== FLOATING NAVIGATION ===== */
.floating-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 1rem;
}

.fab-main {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(139, 92, 246, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    position: relative;
}

.fab-main:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.6), 0 6px 16px rgba(139, 92, 246, 0.4);
}

/* Enhanced tooltip styling */
.fab-main::before {
    content: attr(title);
    position: absolute;
    right: 70px;
    bottom: 8px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
    border: 1px solid rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.fab-main:hover::before {
    opacity: 1;
}

.fab-main:active {
    transform: scale(0.95);
}

.fab-options {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.75rem;
    animation: fabSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fabSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.fab-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    text-decoration: none;
    animation: fabOptionPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Enhanced tooltip for fab-option */
.fab-option::after {
    content: attr(title);
    position: absolute;
    right: 60px;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    line-height: 1.4;
    max-width: 180px;
    text-align: left;
}

.fab-option:hover::after {
    opacity: 1;
}

@keyframes fabOptionPop {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(10px);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.fab-option:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.fab-option:active {
    transform: scale(0.95);
}

/* Staggered animation for multiple options */
.fab-option:nth-child(1) {
    animation-delay: 0s;
}

.fab-option:nth-child(2) {
    animation-delay: 0.05s;
}

.fab-option:nth-child(3) {
    animation-delay: 0.1s;
}

.fab-option:nth-child(4) {
    animation-delay: 0.15s;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .floating-nav {
        bottom: 1rem;
        right: 1rem;
    }

    .fab-main {
        width: 55px;
        height: 55px;
    }

    .fab-option {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* ===== MODAL STYLES ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.modal-body {
    padding: 30px;
    max-height: calc(90vh - 100px);
    overflow-y: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

