/*
 * Mockup — Campus Digital Tècnica Estructural
 * Sistema de disseny alineat amb el tema real (style.css)
 * v1.0.0 — Pre-maqueta per validació del client
 *
 * DISCLAIMER: Aquest CSS és autònom i no depèn de WordPress.
 * Serveix exclusivament per visualitzar el prototip al navegador.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

/*
 * Sistema de disseny extret de tecnica-estructural.com (Maxcoach + Elementor)
 * CSS custom properties (variables) del tema en producció:
 *
 *   --maxcoach-color-primary:            #1f2d33
 *   --maxcoach-color-secondary:          #c7532d
 *   --maxcoach-color-text:               #66625f
 *   --maxcoach-color-heading:            #1f2d33
 *   --maxcoach-color-link:               #53626c
 *   --maxcoach-color-link-hover:         #c7532d
 *   --maxcoach-typography-body:          Gilroy, 15px, 400, line-height 1.74
 *   --maxcoach-typography-headings:      Playfair Display (via Elementor)
 */

:root {
    /* Colors corporatius */
    --color-primary: #2C404D;
    --color-primary-rgb: 44, 64, 77;
    --color-primary-light: #8CA3B4;
    --color-secondary: #D14216;
    --color-secondary-light: #E8A27D;
    --color-text-body: #66625F;
    --color-text-heading: #2C404D;
    --color-link: #8CA3B4;
    --color-link-hover: #D14216;
    --color-white: #FFFFFF;
    --color-bg-light: #F7F5F2;
    --color-border: #8CA3B4;
    --color-border-light: rgba(140, 163, 180, 0.35);

    /* Nivells */
    --color-level-1: #2C404D;
    --color-level-2: #8CA3B4;
    --color-level-3: #D14216;
    --color-text-muted: #8C8986;

    /* Estats */
    --color-error-bg: #f8d7da;
    --color-error-text: #721c24;
    --color-success-bg: #e6f4ea;
    --color-success-text: #137333;
    --color-warning-bg: #fef7e0;
    --color-warning-text: #b06000;

    /* Tipografia — extreta del tema en producció */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-body: 20px;
    --font-weight-body: 400;
    --line-height-body: 1.74;

    /* Dimensions — brutalista, sense border-radius */
    --radius-container: 0px;
    --radius-button: 0px;
    --spacing-base: 8px;
    --section-gap: 40px;

    /* Layout */
    --content-max-width: 1170px;
}

/* ================================================================
   RESET & BASE
   ================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    color: var(--color-text-body);
    background-color: var(--color-bg-light);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    margin-bottom: 0.5em;
    font-weight: 600;
}

h1 { font-size: 47px; line-height: 1.1; }
h2 { font-size: 37px; line-height: 1.2; }
h3 { font-size: 26px; line-height: 1.3; }
h4 { font-size: 21px; line-height: 1.4; }

p {
    margin-bottom: 1em;
    color: var(--color-text-muted);
}

button, input, select, textarea {
    font-family: var(--font-body);
    font-size: 18px;
}

/* ================================================================
   BOTONS — estil brutalista (sense border-radius)
   ================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--color-primary);
    color: var(--color-white);
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-button);
    cursor: pointer;
    font-weight: 700;
    font-size: 17px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    background-color: var(--color-secondary);
    color: var(--color-white);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-xs {
    padding: 6px 14px;
    font-size: 15px;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-full {
    width: 100%;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ================================================================
   FORMULARIS
   ================================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-container);
    background-color: var(--color-white);
    color: var(--color-text-body);
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.form-control[readonly] {
    background-color: var(--color-bg-light);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select[multiple].form-control {
    height: auto;
    min-height: 160px;
    padding: 6px;
}

select[multiple].form-control option {
    padding: 4px 8px;
    font-size: 17px;
}

select[multiple].form-control optgroup {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-multi-select {
    position: relative;
}

.multi-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.multi-select-trigger:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    outline: none;
}

.multi-select-text {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.multi-select-arrow {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-left: 8px;
    transition: transform 0.2s ease;
}

.custom-multi-select.open .multi-select-arrow {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    border: 1px solid var(--color-primary);
    border-top: none;
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
}

.custom-multi-select.open .multi-select-dropdown {
    display: block;
}

.multi-select-group-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px 2px 12px;
    border-bottom: 1px solid var(--color-border-light);
    margin-top: 6px;
}

.multi-select-group-label:first-child {
    margin-top: 0;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    font-size: 17px;
    color: var(--color-text-body);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.multi-select-option:hover {
    background-color: var(--color-bg-light);
}

.multi-select-option input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.multi-select-placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row-label {
    flex: 1 1 180px;
    min-width: 140px;
}

.form-row-date {
    flex: 1 1 160px;
    min-width: 140px;
}

.form-row-time {
    flex: 1 1 120px;
    min-width: 100px;
}

.form-row-text {
    flex: 1 1 200px;
    min-width: 140px;
}

.form-row-number {
    flex: 1 1 100px;
    min-width: 80px;
}

.form-row-remove {
    flex: 0 0 auto;
    align-self: flex-end;
    margin-bottom: 4px;
}

.group-container {
    border: 1px solid var(--color-border);
    padding: 16px;
    margin-bottom: 20px;
    background: var(--color-bg-light);
}

.group-header {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

/* ================================================================
   TAULES
   ================================================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background-color: var(--color-white);
}

th {
    background-color: var(--color-bg-light);
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 12px 14px;
    border-bottom: 2px solid var(--color-border);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 18px;
}

/* ================================================================
   BADGES
   ================================================================ */

.badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--color-bg-light);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: transparent;
}

.badge-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: transparent;
}

.badge-finished {
    background-color: var(--color-bg-light);
    color: var(--color-text-body);
    border-color: var(--color-border);
}

.badge-error {
    background-color: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: transparent;
}

/* ================================================================
   LAYOUT DE L'APLICACIÓ (Header + Sidebar + Main)
   ================================================================ */

.app-header {
    position: sticky;
    top: 0;
    height: 64px;
    background-color: var(--color-primary);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.app-header .logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 24px;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-img {
    height: 36px;
    width: auto;
}

.app-header .logo-accent {
    font-weight: 400;
    font-size: 17px;
    color: var(--color-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logout {
    color: var(--color-white);
    border-color: rgba(255,255,255,0.3);
}

.sidebar-version {
    padding: 0 24px;
    font-size: 15px;
    color: var(--color-text-muted);
}

.app-container {
    display: flex;
    min-height: calc(100vh - 64px);
}

.app-sidebar {
    width: 20%;
    min-width: 260px;
    background-color: var(--color-white);
    border-right: 1px solid var(--color-border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease, border 0.3s ease;
    overflow: hidden;
}

.app-sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 24px 0;
    border-right: none;
}

.app-main {
    flex: 1;
    padding: 40px 24px;
    max-width: 90%;
    margin: 0 auto;
    width: 100%;
    transition: max-width 0.3s ease;
}

.app-main.expanded {
    max-width: 95%;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 26px;
    cursor: pointer;
    padding: 4px 12px 4px 0;
    line-height: 1;
    font-family: inherit;
    display: flex;
    align-items: center;
    transition: opacity 0.2s ease;
}

.sidebar-toggle:hover {
    opacity: 0.7;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 18px;
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-item.active a,
.sidebar-item a:hover {
    color: var(--color-primary);
    background-color: var(--color-bg-light);
    border-left-color: var(--color-primary);
}

/* ================================================================
   TARGETES (CARDS)
   ================================================================ */

.card {
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-container);
    padding: 28px;
    margin-bottom: 24px;
}

.card-title {
    margin-bottom: 16px;
    font-size: 24px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 10px;
}

.card-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ================================================================
   GRIDS
   ================================================================ */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.grid-profile {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ================================================================
   UTILITATS DE TARGETES
   ================================================================ */

.card-title-flush {
    margin: 0;
    border-bottom: none;
}

.card-title-compact {
    border-bottom: none;
    margin-bottom: 8px;
}

.card-subtitle {
    font-weight: 400;
    font-size: 16px;
    color: var(--color-text-muted);
    display: inline;
}

.field-hint {
    font-size: 15px;
    color: var(--color-text-muted);
    margin-top: 4px;
    margin-bottom: 0;
}

.profile-field {
    font-size: 18px;
}

.profile-field strong {
    display: block;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

/* ================================================================
   VISTES (visibilitat condicional)
   ================================================================ */

.view-section {
    display: none;
}

.view-section.active-view {
    display: block;
}

.fase-badge {
    display: inline-block;
    font-size: 15px;
    font-weight: 700;
    padding: 3px 8px;
    margin-bottom: 8px;
    color: var(--color-secondary);
    border: 2px solid var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.level-1 {
    color: var(--color-level-1);
    border-color: var(--color-level-1);
}

.level-2 {
    color: var(--color-level-2);
    border-color: var(--color-level-2);
}

.level-3 {
    color: var(--color-level-3);
    border-color: var(--color-level-3);
}

/* ================================================================
   VISTA LOGIN
   ================================================================ */

.login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--color-bg-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-container {
    width: 100%;
    max-width: 420px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    padding: 40px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 29px;
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--color-text-muted);
    font-size: 17px;
}

.login-logo-img {
    max-width: 120px;
    height: auto;
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.demo-selectors {
    margin-top: 24px;
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
    text-align: center;
}

.demo-selectors p {
    font-size: 16px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.demo-btn-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ================================================================
   VISTA ALUMNES (Fase 1)
   ================================================================ */

.history-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
    background-color: var(--color-bg-light);
    border: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.history-summary-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 16px;
}

.history-summary-module {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 17px;
    color: var(--color-primary);
}

.history-summary-detail {
    font-size: 16px;
    color: var(--color-text-muted);
}

.docs-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.docs-filter-search {
    flex: 1;
    min-width: 220px;
}

.docs-filter-level {
    width: 180px;
    flex-shrink: 0;
}

.badge-level {
    font-size: 13px;
    background-color: transparent;
    border: 1px solid var(--color-primary-light);
    color: var(--color-primary-light);
    margin-top: 8px;
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.doc-card {
    border: 1px solid var(--color-border);
    padding: 18px;
    background-color: var(--color-white);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.doc-card.locked {
    background-color: var(--color-bg-light);
    opacity: 0.7;
}

.doc-card h4 {
    font-size: 20px;
    margin-bottom: 8px;
}

.doc-card p {
    font-size: 17px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

/* ================================================================
   VISTA FORMADORS (Fase 2) — files desplegables
   ================================================================ */

.course-row-main {
    cursor: pointer;
    background-color: var(--color-white);
}

.course-row-main:hover {
    background-color: var(--color-bg-light);
}

.course-details-row {
    display: none;
    background-color: var(--color-bg-light);
}

.course-details-row.open-row {
    display: table-row;
}

.course-detail-panel {
    padding: 16px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
}

.commission-positive {
    color: var(--color-success-text);
    font-weight: 600;
}

/* ================================================================
   VISTA ADMIN (Fase 3)
   ================================================================ */

.btn-danger {
    background-color: var(--color-secondary);
    color: var(--color-white);
    border: none;
}

.btn-danger:hover {
    opacity: 0.8;
}

.search-bar {
    display: flex;
    gap: 12px;
}

.search-filter {
    width: 200px;
    flex-shrink: 0;
}

.form-input-sm {
    padding: 4px 8px;
    font-size: 17px;
}

.form-select-sm {
    padding: 4px;
    font-size: 16px;
}

.config-block {
    min-width: 0;
}

.config-block h4 {
    font-size: 18px;
    margin-bottom: 4px;
}

/* ================================================================
   VISTA LMS (Fase 4)
   ================================================================ */

.lms-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
}

.lms-sidebar {
    border-right: 1px solid var(--color-border);
    padding: 16px;
    background: var(--color-bg-light);
}

.lms-tree-title {
    font-size: 17px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.lms-menu {
    list-style: none;
}

.lms-item a {
    display: block;
    padding: 8px 12px;
    font-size: 17px;
    color: var(--color-text-body);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.lms-item.active a {
    font-weight: 700;
    background: var(--color-white);
    border-left-color: var(--color-primary);
    color: var(--color-primary);
}

.lms-item a:hover {
    background: var(--color-white);
    border-left-color: var(--color-border);
}

.lms-content {
    padding: 24px;
}

.lms-modes {
    margin-top: 24px;
}

.lms-mode-block h4 {
    font-size: 18px;
    margin-bottom: 4px;
}

.lms-mode-block p {
    font-size: 17px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.video-mock {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: var(--color-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    margin-bottom: 16px;
    position: relative;
    font-family: var(--font-heading);
    font-size: 18px;
}

.video-security-notice {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(44, 64, 77, 0.92);
    color: var(--color-secondary);
    padding: 8px;
    text-align: center;
    font-size: 15px;
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ================================================================
   ALERTES I MISSATGES
   ================================================================ */

.alert-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    padding: 16px 20px;
    margin-bottom: 20px;
    border-left: 4px solid var(--color-success-text);
}

.alert-error {
    background-color: var(--color-error-bg);
    color: var(--color-error-text);
    padding: 16px 20px;
    margin-bottom: 20px;
    border-left: 4px solid var(--color-error-text);
}

.empty-notice {
    color: var(--color-text-muted);
    font-style: italic;
    font-size: 18px;
}

.hidden {
    display: none;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        position: relative;
    }

    .app-header {
        padding: 0 16px;
        height: 56px;
    }

    .app-header .logo {
        font-size: 20px;
    }

    .app-header .logo-accent {
        font-size: 13px;
    }

    .header-actions {
        gap: 10px;
    }

    .app-sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        z-index: 900;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--color-border);
        box-shadow: none;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.08);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.3);
        z-index: 899;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .app-main {
        padding: 24px 12px;
    }

    .card {
        padding: 20px 16px;
    }

    .grid-2,
    .grid-3,
    .lms-layout {
        grid-template-columns: 1fr;
    }

    .card-action-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .lms-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .docs-filters {
        flex-direction: column;
    }

    .docs-filter-level {
        width: 100%;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-filter {
        width: 100%;
    }

    .btn-row {
        flex-direction: column;
    }

    .login-container {
        padding: 28px 20px;
    }

    .grid-profile {
        grid-template-columns: 1fr;
    }
}

/* Telèfon (≤480px) */
@media (max-width: 480px) {
    .app-header .logo {
        font-size: 16px;
    }

    .header-logout {
        padding: 6px 10px;
        font-size: 13px;
    }

    .app-main {
        padding: 16px 8px;
    }

    .card {
        padding: 16px 12px;
        margin-bottom: 16px;
    }

    table {
        font-size: 16px;
    }

    th, td {
        padding: 8px 10px;
    }

    .course-detail-panel table th,
    .course-detail-panel table td {
        padding: 6px 8px;
        font-size: 16px;
    }

    .course-detail-panel {
        padding: 10px;
    }

    .form-select-sm {
        padding: 8px;
        font-size: 16px;
        min-height: 44px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 16px;
    }

    .btn-xs {
        padding: 8px 14px;
        font-size: 15px;
    }

    .demo-btn-group {
        flex-direction: column;
        align-items: center;
    }

    .docs-grid {
        grid-template-columns: 1fr;
    }

    .fase-badge {
        font-size: 15px;
    }
}

/* Cursos: layout de 2 línies en mòbil (sense scroll lateral) */
@media (max-width: 640px) {
    #coursesTable,
    #coursesTable tbody {
        display: block;
    }

    #coursesTable thead {
        display: none;
    }

    #coursesTable .course-row-main {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid var(--color-border);
        margin-bottom: 10px;
        background-color: var(--color-white);
    }

    #coursesTable .course-row-main td {
        display: block;
        padding: 4px 10px;
        border-bottom: none;
        font-size: 16px;
    }

    /* Línia 1: nom curs + ubicació */
    #coursesTable .course-row-main td:nth-child(1) {
        order: 1;
        flex: 1 1 60%;
        font-weight: 700;
        font-size: 17px;
        padding-top: 10px;
    }

    #coursesTable .course-row-main td:nth-child(2) {
        order: 2;
        flex: 1 1 40%;
        text-align: right;
        color: var(--color-text-muted);
        font-size: 15px;
        padding-top: 10px;
    }

    /* Línia 2: dates + alumnes + estat */
    #coursesTable .course-row-main td:nth-child(3) {
        order: 3;
        flex: 1 1 50%;
        font-size: 16px;
        color: var(--color-text-muted);
    }

    #coursesTable .course-row-main td:nth-child(4) {
        order: 4;
        flex: 1 1 25%;
        font-size: 16px;
        color: var(--color-text-muted);
    }

    #coursesTable .course-row-main td:nth-child(5) {
        order: 5;
        flex: 0 0 auto;
        padding-bottom: 10px;
    }

    /* Llistat d'assistència: 3 línies en mòbil */
    .course-detail-panel table,
    .course-detail-panel tbody,
    .course-detail-panel tr {
        display: block;
    }

    .course-detail-panel thead {
        display: none;
    }

    .course-detail-panel tr {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 1px solid var(--color-border);
        padding: 8px 0;
    }

    .course-detail-panel td {
        display: block;
        padding: 2px 4px;
        border-bottom: none;
    }

    /* Línia 1: nom alumne + idioma */
    .course-detail-panel td:nth-child(1) {
        order: 1;
        flex: 1 1 60%;
        font-weight: 700;
        font-size: 17px;
    }

    .course-detail-panel td:nth-child(2) {
        order: 2;
        flex: 1 1 40%;
        text-align: right;
        color: var(--color-text-muted);
        font-size: 15px;
    }

    /* Línia 2: telèfon */
    .course-detail-panel td:nth-child(3) {
        order: 3;
        flex: 1 1 100%;
        font-size: 16px;
        color: var(--color-text-muted);
    }

    /* Línia 3: estat */
    .course-detail-panel td:nth-child(4) {
        order: 4;
        flex: 1 1 100%;
        padding-bottom: 4px;
    }

    /* Sol·licitud de Nou Curs: botó ample complet */
    .js-form-solicitud .btn {
        width: 100%;
    }

    .js-form-solicitud .form-control {
        min-height: 44px;
    }

    .js-form-solicitud input[type="date"] {
        min-height: 44px;
    }

    /* Comissions: taula en 2 línies, sense scroll lateral */
    .card-action-bar {
        flex-direction: column;
        gap: 10px;
    }

    .card-action-bar .btn {
        width: 100%;
    }

    .card-action-bar + .table-responsive table,
    .card-action-bar + .table-responsive tbody {
        display: block;
    }

    .card-action-bar + .table-responsive thead {
        display: none;
    }

    .card-action-bar + .table-responsive tr {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 1px solid var(--color-border);
        padding: 8px 0;
    }

    .card-action-bar + .table-responsive td {
        display: block;
        padding: 3px 6px;
        border-bottom: none;
        font-size: 16px;
    }

    /* Línia 1: codi + client */
    .card-action-bar + .table-responsive td:nth-child(1) {
        order: 1;
        flex: 1 1 50%;
        font-weight: 700;
    }

    .card-action-bar + .table-responsive td:nth-child(2) {
        order: 2;
        flex: 1 1 50%;
        text-align: right;
    }

    /* Línia 2: data + comissió */
    .card-action-bar + .table-responsive td:nth-child(3) {
        order: 3;
        flex: 1 1 50%;
        color: var(--color-text-muted);
    }

    .card-action-bar + .table-responsive td:nth-child(4) {
        order: 4;
        flex: 1 1 50%;
        text-align: right;
    }

    /* Historial acadèmic: 3 línies en mòbil */
    #historialTable,
    #historialTable tbody {
        display: block;
    }

    #historialTable thead {
        display: none;
    }

    #historialTable tbody tr {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid var(--color-border);
        margin-bottom: 8px;
        padding: 8px 10px;
        background-color: var(--color-white);
    }

    #historialTable tbody td {
        display: block;
        padding: 2px 6px;
        border-bottom: none;
        font-size: 16px;
    }

    /* Línia 1: mòdul + lloc */
    #historialTable td:nth-child(1) {
        order: 1;
        flex: 1 1 55%;
        font-weight: 700;
        font-size: 17px;
        padding-top: 4px;
    }

    #historialTable td:nth-child(2) {
        order: 2;
        flex: 1 1 45%;
        text-align: right;
        color: var(--color-text-muted);
        padding-top: 4px;
    }

    /* Línia 2: data + formador */
    #historialTable td:nth-child(3) {
        order: 3;
        flex: 1 1 45%;
        color: var(--color-text-muted);
    }

    #historialTable td:nth-child(4) {
        order: 4;
        flex: 1 1 55%;
        color: var(--color-text-muted);
        text-align: right;
    }

    /* Línia 3: repetició + estat */
    #historialTable td:nth-child(5) {
        order: 5;
        flex: 1 1 45%;
        color: var(--color-text-muted);
    }

    #historialTable td:nth-child(6) {
        order: 6;
        flex: 1 1 55%;
        text-align: right;
        padding-bottom: 4px;
    }

    /* Certificats: 2 línies en mòbil */
    #certsTable,
    #certsTable tbody {
        display: block;
    }

    #certsTable thead {
        display: none;
    }

    #certsTable tbody tr {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid var(--color-border);
        margin-bottom: 8px;
        padding: 8px 10px;
        background-color: var(--color-white);
    }

    #certsTable tbody td {
        display: block;
        padding: 3px 6px;
        border-bottom: none;
        font-size: 16px;
    }

    /* Línia 1: certificat + codi */
    #certsTable td:nth-child(1) {
        order: 1;
        flex: 1 1 55%;
        font-weight: 700;
        font-size: 17px;
        padding-top: 4px;
    }

    #certsTable td:nth-child(2) {
        order: 2;
        flex: 1 1 45%;
        text-align: right;
        color: var(--color-text-muted);
        padding-top: 4px;
    }

    /* Línia 2: data + acció */
    #certsTable td:nth-child(3) {
        order: 3;
        flex: 1 1 50%;
        color: var(--color-text-muted);
    }

    #certsTable td:nth-child(4) {
        order: 4;
        flex: 1 1 50%;
        text-align: right;
        padding-bottom: 4px;
    }
}
