/* ============================================
   BOXSTORY - BASE CORE STYLES
   Centralized base styles for the entire application
   All measurements in rem for accessibility
   ============================================ */

/* Import base styles from webpages if they exist */
/* This file serves as the central point for base styles */

/* Global resets and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Poppins', sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* Common button styles base */
.btn-base {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

/* Card base styles */
.card-base {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Form base styles - see base_forms.css for comprehensive form patterns */
/* Core form styles are defined in brand-kit-custom.css */

/* Responsive utilities */
@media (max-width: 48rem) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 48.0625rem) {
    .hide-desktop {
        display: none !important;
    }
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-1.25rem);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading spinner base */
.spinner-base {
    border: 0.1875rem solid #f3f3f3;
    border-top: 0.1875rem solid #007bff;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    animation: spin 1s linear infinite;
    margin: 1.25rem auto;
}

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

/* ============================================
   MOBILE APP-STYLE UI
   Native app-like experience on mobile devices
   ============================================ */

/* Mobile-first base adjustments */
@media (max-width: 48rem) {
    /* Root font size for mobile - slightly larger for readability */
    html {
        font-size: 1rem;
        -webkit-text-size-adjust: 100%;
    }

    body {
        font-size: 1rem;
        line-height: 1.5;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Container padding for app-like edges */
    .container,
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* ========== TYPOGRAPHY - App Size ========== */
    h1, .h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.75rem !important;
    }

    h2, .h2 {
        font-size: 1.5rem !important;
        line-height: 1.25 !important;
        margin-bottom: 0.6rem !important;
    }

    h3, .h3 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }

    h4, .h4 {
        font-size: 1.1rem !important;
        line-height: 1.35 !important;
        margin-bottom: 0.4rem !important;
    }

    h5, .h5 {
        font-size: 1rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.35rem !important;
    }

    h6, .h6 {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.3rem !important;
    }

    p {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 0.75rem;
    }

    .lead {
        font-size: 1.05rem !important;
        line-height: 1.5 !important;
    }

    small, .small, .text-sm {
        font-size: 0.8rem !important;
    }

    .text-muted {
        font-size: 0.85rem;
    }

    /* ========== BUTTONS - App Touch Targets ========== */
    /* Minimum 2.75rem touch target for accessibility */
    .btn {
        min-height: 2.75rem !important;
        padding: 0.625rem 1.25rem !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        border-radius: 0.625rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .btn-sm {
        min-height: 2.25rem !important;
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
        border-radius: 0.5rem !important;
    }

    .btn-lg {
        min-height: 3.25rem !important;
        padding: 0.875rem 1.75rem !important;
        font-size: 1.05rem !important;
        border-radius: 0.75rem !important;
    }

    /* Full-width buttons on mobile for easier tapping */
    .btn-block-mobile {
        width: 100% !important;
        display: block !important;
    }

    /* ========== FORMS - App Style Inputs ========== */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    textarea,
    select {
        min-height: 3rem !important;
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        border-radius: 0.625rem !important;
        border-width: 0.09375rem !important;
    }

    .form-control:focus,
    .form-select:focus {
        border-width: 0.125rem !important;
    }

    textarea.form-control {
        min-height: 6.25rem !important;
    }

    .form-label {
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        margin-bottom: 0.375rem !important;
    }

    .form-text,
    .form-hint {
        font-size: 0.8rem !important;
    }

    /* Checkbox and Radio - larger touch targets */
    .form-check-input {
        width: 1.375rem !important;
        height: 1.375rem !important;
        margin-top: 0 !important;
    }

    .form-check-label {
        font-size: 0.95rem !important;
        padding-left: 0.5rem !important;
        line-height: 1.375rem !important;
    }

    /* ========== CARDS - App Style ========== */
    .card {
        border-radius: 0.75rem !important;
        margin-bottom: 1rem !important;
        box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08) !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
    }

    .card-title {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .card-text {
        font-size: 0.9rem !important;
    }

    .card-footer {
        padding: 0.75rem 1rem !important;
    }

    /* ========== LISTS - App Style ========== */
    .list-group-item {
        padding: 0.875rem 1rem !important;
        font-size: 0.95rem !important;
        border-radius: 0 !important;
    }

    .list-group-item:first-child {
        border-top-left-radius: 0.625rem !important;
        border-top-right-radius: 0.625rem !important;
    }

    .list-group-item:last-child {
        border-bottom-left-radius: 0.625rem !important;
        border-bottom-right-radius: 0.625rem !important;
    }

    /* ========== BADGES & PILLS - App Style ========== */
    .badge {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        border-radius: 1.25rem !important;
    }

    /* ========== ALERTS - App Style ========== */
    .alert {
        padding: 0.875rem 1rem !important;
        font-size: 0.9rem !important;
        border-radius: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    /* ========== TABLES - Mobile Friendly ========== */
    .table {
        font-size: 0.85rem !important;
    }

    .table th,
    .table td {
        padding: 0.625rem 0.5rem !important;
    }

    /* ========== MODALS - App Style ========== */
    .modal-content {
        border-radius: 1rem !important;
        margin: 1rem !important;
    }

    .modal-header {
        padding: 1rem !important;
        border-radius: 1rem 1rem 0 0 !important;
    }

    .modal-title {
        font-size: 1.1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
    }

    .modal-footer {
        padding: 0.75rem 1rem !important;
    }

    /* ========== NAV & TABS - App Style ========== */
    .nav-link {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
    }

    .nav-tabs .nav-link {
        border-radius: 0.5rem 0.5rem 0 0 !important;
    }

    .nav-pills .nav-link {
        border-radius: 0.625rem !important;
    }

    /* ========== DROPDOWN - App Style ========== */
    .dropdown-menu {
        border-radius: 0.75rem !important;
        padding: 0.5rem !important;
        box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.15) !important;
    }

    .dropdown-item {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
        border-radius: 0.5rem !important;
    }

    /* ========== SPACING ADJUSTMENTS ========== */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .my-5 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }

    .my-4 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Row gaps reduced on mobile */
    .row.g-4 {
        --bs-gutter-y: 1rem;
        --bs-gutter-x: 0.75rem;
    }

    .row.g-5 {
        --bs-gutter-y: 1.25rem;
        --bs-gutter-x: 1rem;
    }

    /* ========== ICONS - App Size ========== */
    .fa, .fas, .far, .fab, .fal {
        font-size: inherit;
    }

    .icon-sm {
        font-size: 1rem !important;
    }

    .icon-md {
        font-size: 1.25rem !important;
    }

    .icon-lg {
        font-size: 1.5rem !important;
    }

    /* ========== DISPLAY HEADINGS ========== */
    .display-1 {
        font-size: 2.5rem !important;
    }

    .display-2 {
        font-size: 2.25rem !important;
    }

    .display-3 {
        font-size: 2rem !important;
    }

    .display-4 {
        font-size: 1.75rem !important;
    }

    .display-5 {
        font-size: 1.5rem !important;
    }

    .display-6 {
        font-size: 1.25rem !important;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 36rem) {
    html {
        font-size: 0.9375rem;
    }

    .container,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Even more compact on small phones */
    h1, .h1 {
        font-size: 1.5rem !important;
    }

    h2, .h2 {
        font-size: 1.35rem !important;
    }

    h3, .h3 {
        font-size: 1.15rem !important;
    }

    .display-3 {
        font-size: 1.75rem !important;
    }

    .display-4 {
        font-size: 1.5rem !important;
    }

    .display-5 {
        font-size: 1.35rem !important;
    }

    /* Full-width buttons on small screens */
    .btn:not(.btn-sm):not(.btn-icon) {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Stack button groups */
    .btn-group:not(.btn-group-sm) {
        flex-direction: column !important;
        width: 100%;
    }

    .btn-group:not(.btn-group-sm) .btn {
        width: 100%;
        border-radius: 0.625rem !important;
        margin-bottom: 0.5rem;
    }

    /* Cards even more compact */
    .card-body {
        padding: 0.75rem !important;
    }

    .card-header,
    .card-footer {
        padding: 0.625rem 0.75rem !important;
    }
}

/* ========== SAFE AREA FOR NOTCHED PHONES ========== */
@supports (padding: max(0rem)) {
    body {
        padding-left: max(0rem, env(safe-area-inset-left));
        padding-right: max(0rem, env(safe-area-inset-right));
    }

    .footer-bottom {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
    }
}

/* ========== TOUCH OPTIMIZATION ========== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none !important;
    }

    /* Add active state feedback instead */
    .btn:active {
        transform: scale(0.97) !important;
        opacity: 0.9;
    }

    /* Larger touch targets for links */
    a {
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
    }

    /* Disable text selection on interactive elements */
    .btn,
    .nav-link,
    .dropdown-item,
    .list-group-item {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}
