@tailwind base;
@tailwind components;
@tailwind utilities;

/*
 * The existing theme CSS files (lobby/style.css, page/style.css) reference
 * images with paths relative to their location in public/. They are kept as
 * static assets and loaded separately in each blade layout to preserve those
 * relative paths. This file provides the Tailwind layer and Bootstrap-compat
 * components that replace Bootstrap 4.
 */

/* ─── Bootstrap Spacing Compatibility ────────────────────────────
   Bootstrap spacing scale differs from Tailwind.
   Bootstrap 3 = 1rem, Tailwind 3 = 0.75rem.
   These utility overrides keep Bootstrap blade classes working.
──────────────────────────────────────────────────────────────── */
@layer utilities {
  /* Bootstrap mt-3 = 1rem = Tailwind mt-4 */
  .bs-mt-3 { margin-top: 1rem; }
  .bs-mb-3 { margin-bottom: 1rem; }
  .bs-mt-4 { margin-top: 1.5rem; }
  .bs-mb-4 { margin-bottom: 1.5rem; }
  .bs-mt-5 { margin-top: 3rem; }
  .bs-mb-5 { margin-bottom: 3rem; }

  /* Bootstrap display utilities */
  .d-none    { display: none !important; }
  .d-block   { display: block !important; }
  .d-flex    { display: flex !important; }
  .d-inline  { display: inline !important; }
  .d-inline-block { display: inline-block !important; }
  .d-inline-flex  { display: inline-flex !important; }

  @media (min-width: 576px) {
    .d-sm-none  { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex  { display: flex !important; }
  }
  @media (min-width: 768px) {
    .d-md-none  { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex  { display: flex !important; }
    .d-md-inline-block { display: inline-block !important; }
  }
  @media (min-width: 992px) {
    .d-lg-none  { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex  { display: flex !important; }
  }

  /* Bootstrap flex utilities */
  .flex-column      { flex-direction: column !important; }
  .flex-row         { flex-direction: row !important; }
  .flex-md-column   { @media (min-width: 768px) { flex-direction: column !important; } }
  .flex-md-row      { @media (min-width: 768px) { flex-direction: row !important; } }
  .align-items-center  { align-items: center !important; }
  .align-items-start   { align-items: flex-start !important; }
  .align-items-end     { align-items: flex-end !important; }
  .justify-content-center  { justify-content: center !important; }
  .justify-content-between { justify-content: space-between !important; }
  .justify-content-end     { justify-content: flex-end !important; }
  .justify-content-start   { justify-content: flex-start !important; }

  /* Bootstrap width/height */
  .w-100 { width: 100% !important; }
  .h-100 { height: 100% !important; }
  .mw-100 { max-width: 100% !important; }

  /* Bootstrap text */
  .text-muted   { color: #6c757d !important; }
  .text-break   { word-break: break-word !important; overflow-wrap: break-word !important; }
  .font-weight-bold   { font-weight: 700 !important; }
  .font-weight-light  { font-weight: 300 !important; }
  .font-weight-normal { font-weight: 400 !important; }
  .text-left   { text-align: left !important; }
  .text-right  { text-align: right !important; }
  .text-uppercase { text-transform: uppercase !important; }
  .text-lowercase { text-transform: lowercase !important; }

  @media (min-width: 768px) {
    .text-md-center { text-align: center !important; }
    .text-md-left   { text-align: left !important; }
    .text-md-right  { text-align: right !important; }
  }

  /* Bootstrap float */
  .float-left  { float: left !important; }
  .float-right { float: right !important; }
  .float-none  { float: none !important; }
  .clearfix::after { display: block; clear: both; content: ""; }

  /* Bootstrap img */
  .img-fluid { max-width: 100%; height: auto; }

  /* Bootstrap text colours */
  .text-primary { color: #007bff !important; }
  .text-success { color: #28a745 !important; }
  .text-danger  { color: #dc3545 !important; }
  .text-warning { color: #ffc107 !important; }
  .text-info    { color: #17a2b8 !important; }
  .text-white   { color: #fff !important; }
  .text-dark    { color: #343a40 !important; }

  /* Bootstrap background colours */
  .bg-primary { background-color: #007bff !important; }
  .bg-success { background-color: #28a745 !important; }
  .bg-danger  { background-color: #dc3545 !important; }
  .bg-warning { background-color: #ffc107 !important; }
  .bg-info    { background-color: #17a2b8 !important; }
  .bg-dark    { background-color: #343a40 !important; }
  .bg-white   { background-color: #fff !important; }
  .bg-black   { background-color: #000 !important; }

  /* Bootstrap mt-auto / ml-auto */
  .mt-auto { margin-top: auto !important; }
  .mb-auto { margin-bottom: auto !important; }
  .ml-auto { margin-left: auto !important; }
  .mr-auto { margin-right: auto !important; }

  /* Bootstrap sr-only */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }

  /* Bootstrap overflow */
  .overflow-hidden { overflow: hidden !important; }
  .overflow-auto   { overflow: auto !important; }

  /* Bootstrap border */
  .rounded    { border-radius: 0.25rem !important; }
  .rounded-lg { border-radius: 0.3rem !important; }
  .rounded-pill { border-radius: 50rem !important; }
  .border     { border: 1px solid #dee2e6 !important; }
  .border-0   { border: 0 !important; }

  /* Bootstrap position */
  .position-relative { position: relative !important; }
  .position-absolute { position: absolute !important; }
  .position-fixed    { position: fixed !important; }
}

/* ─── Bootstrap Grid System ──────────────────────────────────── */
@layer components {
  .container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
  }
  @media (min-width: 576px) { .container { max-width: 540px; } }
  @media (min-width: 768px) { .container { max-width: 720px; } }
  @media (min-width: 992px) { .container { max-width: 960px; } }
  @media (min-width: 1200px) { .container { max-width: 1140px; } }

  .row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
  }
  .row.m-0 { margin-right: 0; margin-left: 0; }
  .row.mx-0 { margin-right: 0; margin-left: 0; }
  .no-gutters { margin-right: 0; margin-left: 0; }
  .no-gutters > [class*="col-"], .no-gutters > .col { padding-right: 0; padding-left: 0; }

  /* Bootstrap cols */
  [class*="col-"], .col {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
  }
  .col { flex-basis: 0; flex-grow: 1; max-width: 100%; }
  .col.p-0, .col.px-0 { padding-right: 0; padding-left: 0; }
  .col.px-1 { padding-right: 0.25rem; padding-left: 0.25rem; }
  .col-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
  .col-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-9  { flex: 0 0 75%;        max-width: 75%; }
  .col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-12 { flex: 0 0 100%;       max-width: 100%; }
  @media (min-width: 576px) {
    .col-sm-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
    .col-sm-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-3  { flex: 0 0 25%;        max-width: 25%; }
    .col-sm-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-6  { flex: 0 0 50%;        max-width: 50%; }
    .col-sm-12 { flex: 0 0 100%;       max-width: 100%; }
  }
  @media (min-width: 768px) {
    .col-md-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
    .col-md-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3  { flex: 0 0 25%;        max-width: 25%; }
    .col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6  { flex: 0 0 50%;        max-width: 50%; }
    .col-md-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9  { flex: 0 0 75%;        max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%;       max-width: 100%; }
  }
  @media (min-width: 992px) {
    .col-lg-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
    .col-lg-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-3  { flex: 0 0 25%;        max-width: 25%; }
    .col-lg-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-6  { flex: 0 0 50%;        max-width: 50%; }
    .col-lg-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-9  { flex: 0 0 75%;        max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-12 { flex: 0 0 100%;       max-width: 100%; }
  }

  /* Bootstrap Navs / Tabs / Pills */
  .nav { display: flex; flex-wrap: wrap; padding-left: 0; margin-bottom: 0; list-style: none; }
  .nav-link { display: block; padding: 0.5rem 1rem; text-decoration: none; }
  .nav-pills .nav-link { border-radius: 0.25rem; }
  .nav-pills .nav-link.active { color: #fff; background-color: #007bff; }
  .flex-column { flex-direction: column; }
  .tab-content > .tab-pane { display: none; }
  .tab-content > .active { display: block; }
  .fade { transition: opacity 0.15s linear; opacity: 0; }
  .fade.show { opacity: 1; }
  .tab-pane.fade { display: block; opacity: 0; pointer-events: none; }
  .tab-pane.fade.show { opacity: 1; pointer-events: auto; }
  .tab-pane.active { display: block; }

  /* Bootstrap Buttons */
  .btn {
    display: inline-block;
    font-weight: 400;
    color: #212529;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
                border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    text-decoration: none;
  }
  .btn:focus, .btn:hover { outline: 0; }
  .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; line-height: 1.5; border-radius: 0.2rem; }
  .btn-lg { padding: 0.5rem 1rem; font-size: 1.25rem; line-height: 1.5; border-radius: 0.3rem; }
  .btn-primary  { color: #fff; background-color: #007bff; border-color: #007bff; }
  .btn-primary:hover  { background-color: #0069d9; border-color: #0062cc; }
  .btn-secondary { color: #fff; background-color: #6c757d; border-color: #6c757d; }
  .btn-secondary:hover { background-color: #5a6268; }
  .btn-success  { color: #fff; background-color: #28a745; border-color: #28a745; }
  .btn-success:hover  { background-color: #218838; }
  .btn-danger   { color: #fff; background-color: #dc3545; border-color: #dc3545; }
  .btn-danger:hover   { background-color: #c82333; }
  .btn-warning  { color: #212529; background-color: #ffc107; border-color: #ffc107; }
  .btn-info     { color: #fff; background-color: #17a2b8; border-color: #17a2b8; }
  .btn-light    { color: #212529; background-color: #f8f9fa; border-color: #f8f9fa; }
  .btn-dark     { color: #fff; background-color: #343a40; border-color: #343a40; }
  .btn-outline-primary { color: #007bff; border-color: #007bff; background: transparent; }
  .btn-outline-primary:hover { color: #fff; background-color: #007bff; }
  .btn-outline-secondary { color: #6c757d; border-color: #6c757d; background: transparent; }
  .btn-outline-secondary:hover { color: #fff; background-color: #6c757d; }
  .btn-outline-danger { color: #dc3545; border-color: #dc3545; background: transparent; }
  .btn-outline-danger:hover { color: #fff; background-color: #dc3545; }
  .btn[disabled], .btn:disabled { opacity: 0.65; cursor: not-allowed; pointer-events: none; }

  /* Bootstrap Forms */
  .form-group { margin-bottom: 1rem; }
  .form-label { display: inline-block; margin-bottom: 0.5rem; }
  .form-control {
    display: block;
    width: 100%;
    height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  }
  .form-control:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
  }
  .form-control-lg {
    height: calc(1.5em + 1rem + 2px);
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    line-height: 1.5;
    border-radius: 0.3rem;
  }
  .form-control-sm {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
  }
  .form-check { position: relative; display: block; padding-left: 1.25rem; }
  .form-check-input { position: absolute; margin-top: 0.3rem; margin-left: -1.25rem; }
  .form-text { display: block; margin-top: 0.25rem; font-size: 0.875em; }

  /* Bootstrap Alerts */
  .alert {
    position: relative;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
  }
  .alert-success  { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
  .alert-danger   { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
  .alert-warning  { color: #856404; background-color: #fff3cd; border-color: #ffeeba; }
  .alert-info     { color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; }

  /* Bootstrap Badges */
  .badge {
    display: inline-block;
    padding: 0.25em 0.4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
  }
  .badge-primary { color: #fff; background-color: #007bff; }
  .badge-success { color: #fff; background-color: #28a745; }
  .badge-danger  { color: #fff; background-color: #dc3545; }
  .badge-warning { color: #212529; background-color: #ffc107; }
  .badge-info    { color: #fff; background-color: #17a2b8; }
  .bg-warning.badge { color: #212529; }
  .bg-success.badge { color: #fff; }
  .bg-danger.badge  { color: #fff; }
  .rounded-pill { border-radius: 50rem !important; }

  /* Bootstrap Card */
  .card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,0.125);
    border-radius: 0.25rem;
  }
  .card-body { flex: 1 1 auto; min-height: 1px; padding: 1.25rem; }
  .card-header { padding: 0.75rem 1.25rem; margin-bottom: 0; background-color: rgba(0,0,0,0.03); border-bottom: 1px solid rgba(0,0,0,0.125); }
  .card-title { margin-bottom: 0.75rem; }

  /* Bootstrap Table */
  .table { width: 100%; margin-bottom: 1rem; color: #212529; border-collapse: collapse; }
  .table th, .table td { padding: 0.75rem; vertical-align: top; border-top: 1px solid #dee2e6; }
  .table thead th { vertical-align: bottom; border-bottom: 2px solid #dee2e6; }
  .table-responsive { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(0,0,0,0.05); }
  .table-hover tbody tr:hover { background-color: rgba(0,0,0,0.075); }
  .table-bordered { border: 1px solid #dee2e6; }
  .table-bordered th, .table-bordered td { border: 1px solid #dee2e6; }
  .table-dark { color: #fff; background-color: #343a40; }
  .table-dark th, .table-dark td { border-color: #454d55; }
  .thead-dark th { color: #fff; background-color: #343a40; border-color: #454d55; }
  .thead-light th { color: #495057; background-color: #e9ecef; border-color: #dee2e6; }

  /* Bootstrap Progress */
  .progress {
    display: flex;
    height: 1rem;
    overflow: hidden;
    font-size: 0.75rem;
    background-color: #e9ecef;
    border-radius: 0.25rem;
  }
  .progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background-color: #007bff;
    transition: width 0.6s ease;
  }
  .progress-bar-striped { background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent); background-size: 1rem 1rem; }

  /* Bootstrap Modal (Vanilla JS powered via user.js) */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1050;
    display: none;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
  }
  .modal.show { display: flex !important; align-items: center; }
  .modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0;
    z-index: 1040;
    transition: opacity 0.15s linear;
  }
  .modal-backdrop.show { opacity: 0.5; }
  .modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem auto;
    max-width: 500px;
    pointer-events: none;
  }
  .modal-dialog-centered { align-self: center; }
  .modal-lg { max-width: 800px; }
  .modal-sm { max-width: 300px; }
  .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 0.3rem;
    outline: 0;
  }
  .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
  }
  .modal-title { margin-bottom: 0; line-height: 1.5; }
  .modal-body { position: relative; flex: 1 1 auto; padding: 1rem; }
  .modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
  }
  .modal-footer > * { margin: 0.25rem; }
  .close {
    float: right;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    opacity: 0.5;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
  }
  .close:hover { opacity: 0.75; }
  body.modal-open { overflow: hidden; }

  /* Bootstrap Spinner (replaces spinner-grow and spinner-border) */
  @keyframes spinner-border { to { transform: rotate(360deg); } }
  @keyframes spinner-grow { 0% { transform: scale(0); } 50% { opacity: 1; transform: none; } }

  .spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
  }
  .spinner-border-sm { width: 1rem; height: 1rem; border-width: 0.2em; }

  .spinner-grow {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    background-color: currentColor;
    border-radius: 50%;
    opacity: 0;
    animation: spinner-grow 0.75s linear infinite;
  }
  .spinner-grow-sm { width: 1rem; height: 1rem; }

  /* Bootstrap Pagination */
  .pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    border-radius: 0.25rem;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .page-link {
    position: relative;
    display: block;
    padding: 0.5rem 0.75rem;
    margin-left: -1px;
    line-height: 1.25;
    color: #007bff;
    background-color: #fff;
    border: 1px solid #dee2e6;
    text-decoration: none;
    cursor: pointer;
  }
  .page-link:hover { color: #0056b3; background-color: #e9ecef; border-color: #dee2e6; }
  .page-item.active .page-link { color: #fff; background-color: #007bff; border-color: #007bff; }
  .page-item.disabled .page-link { color: #6c757d; pointer-events: none; background-color: #fff; border-color: #dee2e6; }
}
