/* ========================================
   IMPRESSÃO
======================================== */
@media print {

    body,
    body::before {
        background: var(--impressao-branco);
    }

    .header,
    .controls,
    .save-indicator,
    .menu-overlay,
    .menu-toggle,
    .side-menu,
    .tabs-header {
        display: none !important;
    }

    .sheet-container {
        box-shadow: none;
        padding: 15px;
        background: var(--impressao-branco);
    }

    .tab-content {
        display: block !important;
        page-break-before: always;
    }

    .tab-content:first-child {
        page-break-before: auto;
    }

    .input-label {
        color: var(--impressao-preto) !important;
    }

    .input-group input,
    .input-group textarea,
    .input-group select {
        background-color: var(--impressao-branco) !important;
    }

    .character-bonus-box {
        background: var(--cor13);
    }

    .character-bonus-label {
        color: var(--impressao-preto) !important;
        text-shadow: none !important;
    }

    .section {
        background: var(--impressao-branco);
    }

    .ddt-attribute-box {
        background: var(--cor13);
    }

    .ddt-attribute-box.proficient {
        background: var(--cor18);
    }

    .character-attribute-label,
    .character-attribute-modifier {
        color: var(--impressao-preto) !important;
        text-shadow: none !important;
    }

    * {
        color: var(--impressao-preto) !important;
        text-shadow: none !important;
    }

    input,
    textarea,
    select {
        background: var(--impressao-branco) !important;
        border: 1px solid var(--impressao-preto) !important;
        color: var(--impressao-preto) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   TABLET (768px)
======================================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .app-container {
        max-width: 100%;
    }

    .header {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .controls {
        position: sticky;
        top: 0;
        background: var(--cor1);
        padding: 10px;
        margin-bottom: 15px;
        z-index: 100;
        box-shadow: 0 2px 10px var(--sombra-preta);
        gap: 8px;
        flex-direction: column;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        width: 100%;
        min-width: auto;
    }

    .menu-toggle {
        top: 10px;
        right: 10px;
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .side-menu {
        width: 280px;
        right: -300px;
    }

    .side-menu .controls {
        margin-top: 50px;
        gap: 12px;
    }

    .sheet-container {
        padding: 15px;
        border: 2px solid var(--cor11);
    }

    .sheet-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .sheet-grid-details {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .character-info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    [style*="grid-template-columns: 1fr 1fr 1fr 2fr"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* ── Bonus Box ── */
    .character-bonus-box {
        flex-direction: row;
        gap: 15px;
        padding: 15px 10px;
    }

    .character-bonus-check {
        width: 45px;
        height: 45px;
    }

    .bonus-value {
        width: 55px;
        height: 55px;
        font-size: 2rem;
    }

    .character-bonus-label {
        font-size: 0.85rem;
    }

    /* ── Atributos ── */
    .character-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .ddt-attribute-box {
        padding: 10px 10px;
    }

    .character-attribute-label {
        font-size: 0.65rem;
        margin-bottom: 5px;
    }

    .character-attribute-input {
        font-size: 1.5rem;
        padding: 4px;
        min-height: 35px;
    }

    .character-attribute-modifier {
        font-size: 1.4rem;
    }

    .character-saving-throw {
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .character-proficiency-check {
        top: 32px;
        left: 250px;
        width: 25px;
        height: 25px;
    }

    .character-proficiency-check:checked::after {
        font-size: 18px;
    }

    /* ── Seções ── */
    .section {
        padding: 12px;
        margin-bottom: 15px;
        border-left: 4px solid var(--cor11);
    }

    .section-title {
        font-size: 0.85rem;
        margin-bottom: 8px;
        padding-bottom: 4px;
    }

    .input-group {
        margin-bottom: 10px;
    }

    .input-label {
        font-size: 0.7rem;
        margin-bottom: 4px;
    }

    input,
    textarea,
    select {
        font-size: 0.95rem;
        padding: 10px;
        min-height: 44px;
    }

    textarea {
        min-height: 80px;
    }

    /* ── Perícias ── */
    .character-skills-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .character-skill-item {
        padding: 10px;
        border-left: 4px solid var(--cor3);
    }

    .ddt-skill-name {
        font-size: 0.95rem;
    }

    .ddt-skill-value {
        font-size: 0.95rem;
        min-width: 45px;
    }

    .ddt-skill-prof-select {
        min-width: 90px;
        font-size: 0.9rem;
        padding: 6px 10px;
        min-height: 44px;
    }

    /* ── Combate (grids legados usados em HTML) ── */
    .combat-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* ── Moedas ── */
    .character-currency-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    /* ── Inventário ── */
    .inventory-item {
        grid-template-columns: 80px 1fr auto;
        gap: 8px;
        padding: 8px;
    }

    /* ── Ataques ── */
    .attack-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .attack-item input {
        width: 100%;
        min-height: 44px;
    }

    .attack-item .delete-btn {
        width: 100%;
        padding: 12px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .delete-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    /* ── Magias ── */
    .character-character-spell-slots-grid,
    .character-spell-slots-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .spell-details-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .character-slot-current,
    .character-slot-max {
        width: 45px;
        font-size: 1rem;
    }

    /* ── Abas ── */
    .tabs-header {
        flex-direction: column;
        gap: 8px;
    }

    .tab-btn {
        min-width: 100%;
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    /* ── Modal ── */
    .modal-content {
        padding: 20px;
        max-height: 85vh;
        margin: 10px;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .character-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
    }

    .character-item .delete-btn {
        width: 100%;
        min-height: 44px;
    }

    /* ── Indicador de salvamento ── */
    .save-indicator {
        bottom: 20px;
        right: 20px;
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* ── Item Mágico ── */
    .ddt-magic-item-header {
        grid-template-columns: 1fr auto;
        gap: 8px;
    }

    .ddt-magic-item-sync {
        grid-column: 1 / -1;
        justify-content: flex-start;
        padding: 8px 0;
        border-top: 1px solid var(--cor11);
        margin-top: 8px;
    }

    /* ── Imagem do personagem ── */
    .image-preview {
        width: 250px;
        height: 330px;
    }

    .image-controls {
        width: 100%;
    }

    .image-controls .btn {
        flex: 1;
        min-width: 120px;
    }

    input[type="checkbox"] {
        min-width: 24px;
        min-height: 24px;
        cursor: pointer;
    }

    input[type="number"] {
        font-size: 1rem;
    }

    button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        min-height: 44px;
    }
}

/* ========================================
   CELULAR PEQUENO (480px)
======================================== */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .header p {
        font-size: 0.85rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 10px 15px;
    }

    .character-stats-grid {
        grid-template-columns: 1fr;
    }

    .ddt-attribute-box {
        padding: 12px;
    }

    .character-proficiency-check {
        top: 82px;
        left: 250px;
        width: 44px;
        height: 44px;
    }

    .character-attribute-input {
        font-size: 1.8rem;
    }

    .character-attribute-modifier {
        font-size: 1.5rem;
    }

    .character-currency-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .section {
        padding: 10px;
    }

    .character-bonus-box {
        flex-direction: column;
        gap: 10px;
    }

    .character-bonus-item {
        width: 100%;
    }

    .character-bonus-check {
        width: 50px;
        height: 50px;
    }

    .bonus-value {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   LANDSCAPE (900px)
======================================== */
@media (max-width: 900px) and (orientation: landscape) {
    .header {
        padding: 15px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .controls {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .btn {
        width: auto;
        min-width: 140px;
    }

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

    .character-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .ddt-attribute-box {
        padding: 8px 5px;
    }

    .character-attribute-input {
        font-size: 1.3rem;
    }

    .character-attribute-modifier {
        font-size: 1.2rem;
    }
}

/* ========================================
   DISPOSITIVOS TOUCH
======================================== */
@media (hover: none) and (pointer: coarse) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    input,
    select,
    textarea,
    button {
        font-size: 16px !important;
    }

    .character-attribute-input {
        font-size: 1.5rem !important;
    }

    .bonus-value {
        font-size: 2rem !important;
    }

    .ddt-skill-prof-select,
    .character-bonus-check,
    .character-proficiency-check,
    .delete-btn,
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    * {
        -webkit-overflow-scrolling: touch;
    }
}