/* public/css/modern-design.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Hide elements with x-cloak until Alpine.js loads */
[x-cloak] {
    display: none !important;
}

:root {
    /* Colors - SaaS Premium Palette */
    --brand-primary: #4F46E5;
    --brand-primary-hover: #4338CA;
    --brand-secondary: #0EA5E9;

    --bg-app: #F9FAFB;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;

    --text-main: #111827;
    --text-muted: #6B7280;
    --text-white: #FFFFFF;

    --border-color: #D1D5DB;
    /* Darker border for better visibility */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --sidebar-width: 280px;
    --sidebar-width-collapsed: 80px;
    --header-height: 64px;
    --bottom-nav-height: 64px;
}

/* Base resets and typography */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* Page header – uniform across admin pages */
.page-header__actions {
    gap: 0.75rem;
}
.page-header-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.75rem;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: box-shadow 0.2s, background-color 0.2s;
}
.page-header-btn-primary:hover {
    background-color: var(--brand-primary-hover);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.page-header-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.page-header-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    background-color: #F3F4F6;
    color: #374151;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.page-header-btn-secondary:hover {
    background-color: #E5E7EB;
    color: #111827;
}
.page-header-divider {
    width: 1px;
    height: 2rem;
    background-color: #E5E7EB;
    flex-shrink: 0;
}

/* Fallback constraints for images and SVGs */
img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/*
 * Do not set fixed width/height on all SVGs: it breaks chart libraries (ApexCharts)
 * and overrides their intrinsic / JS-set dimensions even with high-specificity fixes
 * when load order or library versions differ.
 * Sidebar/header icons use .nav-icon, .bottom-nav-icon, or Tailwind w-* h-* utilities.
 */
svg {
    max-width: 100%;
    height: auto;
    display: inline-block;
    vertical-align: middle;
}

/* Admin reports: reserve space for ApexCharts before JS renders */
.reports-apex-chart {
    width: 100%;
    min-height: 320px;
}

/* Explicit utility fallbacks to prevent layout explosions */
.h-4 {
    height: 1rem !important;
}

.w-4 {
    width: 1rem !important;
}

.h-5 {
    height: 1.25rem !important;
}

.w-5 {
    width: 1.25rem !important;
}

.h-6 {
    height: 1.5rem !important;
}

.w-6 {
    width: 1.5rem !important;
}

.h-8 {
    height: 2rem !important;
}

.w-8 {
    width: 2rem !important;
}

.h-9 {
    height: 2.25rem !important;
}

.w-9 {
    width: 2.25rem !important;
}

.h-10 {
    height: 2.5rem !important;
}

.w-10 {
    width: 2.5rem !important;
}

.flex-shrink-0 {
    flex-shrink: 0 !important;
}

.sidebar-header img {
    width: 2rem !important;
    height: 2rem !important;
}

.sidebar-header .sidebar-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Visibility Fallbacks */
@media (min-width: 1024px) {
    .lg\:hidden {
        display: none !important;
    }

    .lg\:flex {
        display: flex !important;
    }
}

@media (max-width: 1023px) {
    .hidden {
        display: none !important;
    }
}

/* Layout Classes - Mobile First */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    flex: 1;
    width: 100%;
    margin-left: 0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar Styling - Hidden on mobile by default */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease, left 0.3s ease;
    pointer-events: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    padding: 1.5rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.75rem;
    transition: all 0.2s;
    font-weight: 500;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
}

.nav-item:hover {
    background-color: #F3F4F6;
    color: var(--text-main);
}

.nav-item.active {
    background-color: #EEF2FF;
    color: var(--brand-primary);
}

.nav-icon {
    width: 1.5rem !important;
    height: 1.5rem !important;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    pointer-events: auto;
    touch-action: manipulation;
}

@media (min-width: 1024px) {
    .mobile-bottom-nav {
        display: none;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    flex: 1;
    height: 100%;
    padding: 0.5rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.bottom-nav-item.active {
    color: var(--brand-primary);
}

.bottom-nav-icon {
    width: 1.5rem !important;
    height: 1.5rem !important;
    margin-bottom: 2px;
}

/* Modern Card (Bento Style) */
.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

@media (min-width: 768px) {
    .bento-card {
        padding: 1.5rem;
    }
}

.bento-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Modern Table - Responsive Card View */
.data-table-container {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table thead {
    background: #F9FAFB;
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid #E5E7EB;
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: #F9FAFB;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-main);
    vertical-align: middle;
}

@media (max-width: 767px) {
    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        font-size: 0.875rem;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }
}

/* Enhancements for larger screens */
@media (min-width: 1024px) {
    .app-container {
        flex-direction: row;
    }

    .sidebar {
        position: sticky;
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width-collapsed);
    }

    .main-content {
        padding-bottom: 0;
        width: calc(100% - var(--sidebar-width));
    }

    .main-content.sidebar-collapsed {
        width: calc(100% - var(--sidebar-width-collapsed));
    }

    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .nav-label {
        opacity: 0;
        width: 0;
        display: none;
    }

    .sidebar.collapsed .nav-section-label {
        display: none;
    }

    .sidebar.collapsed .nav-item {
        justify-content: center;
        padding: 0.875rem;
    }

    .sidebar.collapsed .nav-icon {
        margin-right: 0;
    }
}

/* Ensure sidebar is completely hidden on mobile/tablet unless explicitly opened */
@media (max-width: 1023px) {
    .sidebar {
        display: none;
    }

    .sidebar.open {
        display: flex;
    }
}

/* Utility Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Modern Form Inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="tel"],
select,
textarea {
    appearance: none;
    background-color: #F8FAFC;
    /* Subtle background to make inputs stand out */
    border: 1.5px solid var(--border-color);
    /* Slightly thicker and darker */
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    /* Better for mobile to prevent zoom */
    line-height: 1.5;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
}

input::placeholder {
    color: #94A3B8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    background-color: #FFFFFF;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

/* Ensure main content can scroll on mobile */
main {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Specific Sidebar overlap prevention */
@media (min-width: 1024px) {
    .main-content {
        transition: padding-left 0.3s ease, margin-left 0.3s ease;
        padding-left: var(--sidebar-width);
    }

    .sidebar {
        position: fixed;
    }

    .main-content.sidebar-collapsed {
        padding-left: var(--sidebar-width-collapsed);
    }
}

/* Prevent content interaction when sidebar is open on mobile */
@media (max-width: 1023px) {
    .main-content.sidebar-open {
        pointer-events: none;
        overflow: hidden;
        touch-action: none;
    }

    .main-content.sidebar-open main {
        pointer-events: none;
        overflow: hidden;
    }
}

/* =============================================
   MULTI-STEP FORM COMPONENTS
   ============================================= */

/* Step Progress Bar */
.multi-step-progress {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: #F9FAFB;
    border-radius: 1rem;
    border: 1px solid #E5E7EB;
}

.step-panel {
    display: none;
}

.step-panel.active {
    display: block;
}

.step-item {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}

.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: calc(1.75rem + 0.5rem);
    right: 0;
    top: 50%;
    height: 2px;
    background: #E5E7EB;
    transform: translateY(-50%);
    transition: background 0.3s ease;
    z-index: 0;
}

.step-item.completed::after {
    background: var(--brand-primary);
}

.step-circle {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid #E5E7EB;
    background: white;
    color: #9CA3AF;
    transition: all 0.3s ease;
    z-index: 1;
    position: relative;
    flex-shrink: 0;
}

.step-item.active .step-circle {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.step-item.completed .step-circle {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: white;
}

.step-label {
    margin-left: 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9CA3AF;
    white-space: nowrap;
    transition: color 0.3s ease;
    background: #F9FAFB; /* Match .multi-step-progress background */
    padding: 0 4px;
    position: relative;
    z-index: 1;
}

.step-item.active .step-label {
    color: var(--brand-primary);
}

.step-item.completed .step-label {
    color: #374151;
}

/* Step Panels */
.step-panel {
    display: none;
    animation: fadeIn 0.3s ease-out forwards;
}

.step-panel.active {
    display: block;
}

/* Form Card */
.admin-form-card {
    background: white;
    border-radius: 1.25rem;
    border: 1px solid #E5E7EB;
    padding: 2rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

/* Form Section */
.form-section {
    margin-bottom: 1.75rem;
}

.form-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #F3F4F6;
}

/* Form Label */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}

.form-hint {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-top: 0.25rem;
}

/* Step Navigation Buttons */
.step-nav {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding-top: 1.5rem;
    border-top: 1px solid #F3F4F6;
    margin-top: 1.5rem;
}

.step-nav .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    background: var(--brand-primary);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.step-nav .btn-primary:hover {
    background: var(--brand-primary-hover);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.step-nav .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #F3F4F6;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s;
}

.step-nav .btn-secondary:hover {
    background: #E5E7EB;
}

.step-nav .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #FEF2F2;
    color: #991B1B;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid #FECACA;
    cursor: pointer;
    transition: background 0.2s;
}

.step-nav .btn-danger:hover {
    background: #FEE2E2;
}

/* Review Summary Card */
.review-summary {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 1rem;
    padding: 1.5rem;
}

.review-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.625rem 0;
    border-bottom: 1px solid #F3F4F6;
    font-size: 0.875rem;
}

.review-row:last-child {
    border-bottom: none;
}

.review-label {
    font-weight: 600;
    color: #6B7280;
    min-width: 9rem;
}

.review-value {
    color: #111827;
    text-align: right;
    font-weight: 500;
}

/* Toggle/Switch Inputs in forms */
.form-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.form-toggle:hover {
    border-color: var(--brand-primary);
    background: #EEF2FF;
}

.form-toggle input[type="checkbox"] {
    margin-top: 0.125rem;
    flex-shrink: 0;
    width: 1.125rem !important;
    height: 1.125rem !important;
}

/* Admin Page Breadcrumb nav */
.admin-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #9CA3AF;
    margin-bottom: 0.5rem;
}

.admin-breadcrumb a {
    color: #6B7280;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.admin-breadcrumb a:hover {
    color: var(--brand-primary);
}

.admin-breadcrumb svg {
    width: 0.875rem !important;
    height: 0.875rem !important;
    flex-shrink: 0;
}
