/* PlanetaJJ UI foundation
 * Centraliza tokens e comportamentos responsivos compartilhados.
 * Regras especificas de cada modulo continuam em app.css.
 */

:root {
    --ui-brand: #f57c00;
    --ui-brand-strong: #e65100;
    --ui-ink: #0b1c2d;
    --ui-muted: #64748b;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f8fafc;
    --ui-border: #dbe3ec;
    --ui-focus: rgba(245, 124, 0, .22);
    --ui-shadow-sm: 0 6px 18px rgba(11, 28, 45, .07);
    --ui-shadow-md: 0 14px 38px rgba(11, 28, 45, .11);
    --ui-radius-sm: 10px;
    --ui-radius-md: 16px;
    --ui-radius-lg: 20px;
    --ui-space-1: 4px;
    --ui-space-2: 8px;
    --ui-space-3: 12px;
    --ui-space-4: 16px;
    --ui-space-5: 20px;
    --ui-space-6: 24px;
    --ui-space-8: 32px;
    --ui-control-height: 44px;
    --ui-content-max: 1600px;
}

html[data-theme='dark'] {
    --ui-ink: #f8fafc;
    --ui-muted: #9fb0c3;
    --ui-surface: #10202e;
    --ui-surface-soft: #142433;
    --ui-border: #2d4254;
    --ui-focus: rgba(251, 146, 60, .25);
    --ui-shadow-sm: 0 8px 22px rgba(0, 0, 0, .2);
    --ui-shadow-md: 0 18px 44px rgba(0, 0, 0, .28);
}

body {
    color: var(--ui-ink);
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
[role='button'],
.menu-item {
    touch-action: manipulation;
}

.main-content {
    min-width: 0;
    padding: clamp(20px, 2.25vw, 36px);
}

.page-header,
.view {
    width: min(100%, var(--ui-content-max));
}

.page-header {
    gap: var(--ui-space-5);
}

.page-title {
    min-width: 0;
    line-height: 1.15;
}

#pageTitle {
    overflow-wrap: anywhere;
}

.user-menu,
.user-identity,
.user-actions {
    min-width: 0;
}

.card,
.dashboard-panel,
.metric-card,
.stat-card {
    border: 1px solid rgba(219, 227, 236, .75);
}

.card-title,
.module-header-copy .card-title {
    font-size: clamp(20px, 1.7vw, 25px);
    line-height: 1.2;
    letter-spacing: -.35px;
}

.module-header-copy {
    min-width: 0;
}

.module-header-copy p,
.card-subtitle {
    max-width: 72ch;
    line-height: 1.45;
}

.btn,
.btn-add,
.btn-secondary,
.btn-export,
.btn-logout {
    min-height: var(--ui-control-height);
    align-items: center;
    justify-content: center;
    line-height: 1.15;
}

.form-input,
.form-select,
.form-textarea,
.search-input {
    min-height: var(--ui-control-height);
    border-width: 1px;
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-sm);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.search-input:focus {
    box-shadow: 0 0 0 4px var(--ui-focus);
}

.form-label,
.toolbar-label {
    line-height: 1.25;
}

.module-card > .module-toolbar,
.module-filter-panel,
.reservation-filters,
.damage-filters,
.reports-filter-panel {
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-md);
}

.reservation-filters,
.damage-filters {
    align-items: end;
}

.reservation-filters .form-group,
.damage-filters .form-group {
    min-width: 0;
}

.reservation-clear-filter {
    min-height: var(--ui-control-height);
}

.table-wrapper,
.report-table-wrapper {
    max-width: 100%;
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-md);
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper > table,
.report-table-wrapper > table {
    width: 100%;
}

th,
td {
    vertical-align: middle;
}

th {
    line-height: 1.25;
}

.actions-column,
.action-buttons {
    white-space: nowrap;
}

.action-buttons {
    min-width: max-content;
}

.btn-action {
    flex: 0 0 auto;
}

.reservation-summary-grid,
.inventory-summary-grid,
.damage-summary-grid,
.reports-stats-grid,
.log-summary-grid {
    align-items: stretch;
}

.reservation-summary-card,
.inventory-summary-card,
.damage-summary-card,
.report-stat-card {
    min-width: 0;
    height: 100%;
}

.reservation-summary-card strong,
.inventory-summary-card strong,
.damage-summary-card strong,
.report-stat-card .stat-value {
    overflow-wrap: anywhere;
}

.modal-content {
    width: min(700px, calc(100vw - 32px));
}

.modal-wide {
    width: min(960px, calc(100vw - 32px));
}

@media (max-width: 1200px) {
    .main-content {
        padding: 24px;
    }

    .reservation-summary-grid,
    .inventory-summary-grid,
    .damage-summary-grid,
    .reports-stats-grid,
    .log-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .page-header {
        align-items: flex-start;
    }

    .user-name {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .module-card > .card-header,
    .analytics-page-card > .card-header {
        gap: var(--ui-space-4);
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .page-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        padding: 16px;
        margin-bottom: 18px;
    }

    .page-title,
    .user-menu {
        width: 100%;
    }

    .page-title {
        justify-content: flex-start;
    }

    .user-menu {
        justify-content: space-between;
        gap: var(--ui-space-3);
        padding-top: var(--ui-space-3);
        border-top: 1px solid var(--ui-border);
    }

    .user-actions {
        gap: var(--ui-space-2);
        padding-left: 0;
        border-left: 0;
    }

    .card,
    .dashboard-panel,
    .metric-card,
    .stat-card {
        border-radius: var(--ui-radius-md);
    }

    .module-card > .card-header,
    .analytics-page-card > .card-header {
        padding: 20px;
    }

    .module-card > .module-toolbar,
    .module-filter-panel,
    .reservation-filters,
    .damage-filters,
    .reports-filter-panel {
        margin-right: 20px;
        margin-left: 20px;
    }

    .materials-toolbar,
    .reservation-filters,
    .damage-filters,
    .inventory-filters,
    .reports-filter-grid,
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .reservation-clear-filter,
    .damage-filters .reservation-clear-filter {
        width: 100%;
    }

    .table-wrapper > table,
    .report-table-wrapper > table {
        min-width: 720px;
    }

    th,
    td {
        padding-right: 14px;
        padding-left: 14px;
    }

    .modal {
        padding: 16px;
    }

    .modal-content,
    .modal-wide {
        width: 100%;
        max-height: calc(100dvh - 32px);
    }
}

@media (max-width: 560px) {
    .main-content {
        padding: 12px;
    }

    .page-header {
        padding: 14px;
        border-radius: 14px;
    }

    .page-title {
        font-size: 21px;
    }

    .user-name {
        max-width: 112px;
        font-size: 14px;
    }

    .module-card > .card-header,
    .analytics-page-card > .card-header {
        padding: 18px 14px;
    }

    .module-card > .card-header,
    .reports-filter-header {
        align-items: stretch;
        flex-direction: column;
    }

    .module-card > .card-header .btn-add,
    .analytics-page-card > .card-header .btn-export,
    .reports-filter-actions,
    .reports-filter-actions > button {
        width: 100%;
    }

    .module-card > .module-toolbar,
    .module-filter-panel,
    .reservation-filters,
    .damage-filters,
    .reports-filter-panel {
        margin-right: 14px;
        margin-left: 14px;
        padding: 14px;
    }

    .reservation-summary-grid,
    .inventory-summary-grid,
    .damage-summary-grid,
    .reports-stats-grid,
    .log-summary-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .reservation-summary-card,
    .inventory-summary-card,
    .damage-summary-card,
    .report-stat-card {
        padding: 18px;
    }

    .damage-tabs {
        width: calc(100% - 28px);
        margin-right: 14px;
        margin-left: 14px;
    }

    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content,
    .modal-wide {
        width: 100%;
        max-height: 94dvh;
        border-radius: 20px 20px 0 0;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer > button {
        width: 100%;
    }
}

@media (max-width: 390px) {
    .user-avatar,
    .theme-toggle,
    .notification-button,
    .btn-logout,
    .mobile-menu-toggle {
        width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .user-actions {
        gap: 6px;
    }

    .user-name {
        max-width: 92px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
