/* =============================================
   ESTILO MINIMALISTA - INSPIRADO NO AMIGA
   VERSÃO RESPONSIVA PARA APPLE
   ============================================= */

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove destaque azul no iOS */
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%; /* Previne zoom automático no iOS */
}

body {
    background: #ffffff;
    color: #000000;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    line-height: 1.6;
    padding: 1.25rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased; /* Melhora renderização no Mac/iOS */
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   CONTAINER PRINCIPAL
   ============================================= */
.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1.25rem;
}

/* =============================================
   CABEÇALHO - ESTILO AMIGA WORKBENCH
   ============================================= */
.header {
    border-bottom: 2px solid #000000;
    padding-bottom: 0.625rem;
    margin-bottom: 1.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.header-title {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    word-break: break-word;
}

.header-user {
    font-size: 0.75rem;
    text-align: right;
    line-height: 1.4;
}

.header-user span {
    display: block;
}

/* =============================================
   MENU DE NAVEGAÇÃO - TOUCH FRIENDLY
   ============================================= */
.menu {
    background: #ffffff;
    border: 2px solid #000000;
    padding: 0;
    margin-bottom: 1.875rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    min-height: 44px; /* Touch target mínimo para iOS */
}

.menu-item {
    padding: 0.75rem 1.25rem;
    border-right: 2px solid #000000;
    text-decoration: none;
    color: #000000;
    font-size: clamp(0.7rem, 1.5vw, 0.8125rem);
    font-family: 'Courier New', Courier, monospace;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px; /* Touch target mínimo para iOS */
    -webkit-touch-callout: none;
    user-select: none;
}

.menu-item:last-child {
    border-right: none;
}

.menu-item:hover,
.menu-item:active {
    background: #000000;
    color: #ffffff;
}

.menu-item.active {
    background: #000000;
    color: #ffffff;
}

.menu-item.logout {
    margin-left: auto;
    border-left: 2px solid #000000;
    border-right: none;
}

/* =============================================
   TÍTULOS
   ============================================= */
h1, h2, h3, h4 {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    margin-bottom: 1.25rem;
    word-break: break-word;
}

h1 {
    font-size: clamp(1.5rem, 5vw, 1.75rem);
    text-transform: uppercase;
    letter-spacing: 1px;
}

h2 {
    font-size: clamp(1.1rem, 3vw, 1.25rem);
    border-bottom: 1px solid #000000;
    padding-bottom: 0.5rem;
}

h3 {
    font-size: clamp(0.95rem, 2vw, 1rem);
}

/* =============================================
   FORMULÁRIOS - TOUCH FRIENDLY
   ============================================= */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.3125rem;
    font-size: clamp(0.7rem, 1.2vw, 0.8125rem);
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem 0.75rem; /* Touch target mínimo */
    border: 2px solid #000000;
    background: #ffffff;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.875rem, 2vw, 1rem);
    color: #000000;
    transition: background 0.2s, border-color 0.2s;
    -webkit-appearance: none; /* Remove estilo padrão do iOS */
    appearance: none;
    border-radius: 0; /* Remove border-radius do iOS */
    min-height: 44px; /* Touch target mínimo */
}

input:focus,
select:focus,
textarea:focus {
    background: #f0f0f0;
    outline: none;
    border-color: #000000;
}

/* Estilo específico para select no iOS */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.2rem;
    padding-right: 2.5rem;
}

/* Remove seta padrão do select no IE/Edge */
select::-ms-expand {
    display: none;
}

textarea {
    max-width: 100%;
    min-height: 80px;
    resize: vertical;
}

/* =============================================
   BOTÕES - TOUCH FRIENDLY
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    min-height: 44px; /* Touch target mínimo para iOS */
    min-width: 44px;
    background: #ffffff;
    border: 2px solid #000000;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.7rem, 1.5vw, 0.8125rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #000000;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
    text-align: center;
    border-radius: 0;
    width: auto;
}

.btn:hover,
.btn:active {
    background: #000000;
    color: #ffffff;
}

.btn-primary {
    background: #000000;
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:active {
    background: #ffffff;
    color: #000000;
}

.btn-danger {
    border-color: #cc0000;
    color: #cc0000;
}

.btn-danger:hover,
.btn-danger:active {
    background: #cc0000;
    color: #ffffff;
}

.btn-success {
    border-color: #006600;
    color: #006600;
}

.btn-success:hover,
.btn-success:active {
    background: #006600;
    color: #ffffff;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* =============================================
   TABELAS - RESPONSIVAS
   ============================================= */
.table-responsive {
    overflow-x: auto;
    margin: 1.25rem 0;
    border: 2px solid #000000;
    -webkit-overflow-scrolling: touch; /* Scroll suave no iOS */
}

table {
    width: 100%;
    min-width: 600px; /* Garante legibilidade em telas pequenas */
    border-collapse: collapse;
    font-size: clamp(0.7rem, 1.5vw, 0.8125rem);
}

th {
    background: #000000;
    color: #ffffff;
    text-align: left;
    padding: 0.75rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    white-space: nowrap;
}

td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #dddddd;
    word-break: break-word;
}

tr:hover td {
    background: #f0f0f0;
}

tr:last-child td {
    border-bottom: none;
}

/* =============================================
   CARDS / PAINÉIS - RESPONSIVOS
   ============================================= */
.card {
    border: 2px solid #000000;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: #ffffff;
    word-break: break-word;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 1.25rem;
    margin: 1.25rem 0;
}

.card-grid .card {
    text-align: center;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
}

.card-grid .card .value {
    font-size: clamp(1.5rem, 5vw, 1.75rem);
    font-weight: bold;
    margin: 0.625rem 0;
    word-break: break-word;
}

.card-grid .card .label {
    font-size: clamp(0.6rem, 1.2vw, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666666;
}

/* =============================================
   MENSAGENS
   ============================================= */
.message {
    padding: 0.75rem 1rem;
    border: 2px solid #000000;
    margin-bottom: 1.25rem;
    font-weight: bold;
    word-break: break-word;
}

.message-success {
    border-color: #006600;
    color: #006600;
}

.message-error {
    border-color: #cc0000;
    color: #cc0000;
}

.message-info {
    border-color: #0066cc;
    color: #0066cc;
}

/* =============================================
   LOGIN - RESPONSIVO
   ============================================= */
.login-container {
    max-width: 400px;
    margin: clamp(2rem, 10vh, 6.25rem) auto;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    border: 2px solid #000000;
    width: 100%;
}

.login-container h1 {
    text-align: center;
    font-size: clamp(1.2rem, 4vw, 1.25rem);
    margin-bottom: 1.875rem;
}

.login-container .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
}

.login-container input {
    max-width: 100%;
}

/* =============================================
   DARF - RESPONSIVO
   ============================================= */
.darf-box {
    border: 4px double #000000;
    padding: clamp(1.25rem, 4vw, 1.875rem);
    margin: 1.25rem 0;
    font-size: clamp(0.7rem, 1.5vw, 0.875rem);
    overflow-x: auto;
}

.darf-box .line {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0.375rem 0;
    border-bottom: 1px dashed #cccccc;
    gap: 0.3125rem;
}

.darf-box .line:last-child {
    border-bottom: none;
}

.darf-box .label {
    font-weight: bold;
    text-transform: uppercase;
    word-break: break-word;
}

.darf-box .value {
    font-weight: bold;
    word-break: break-word;
    text-align: right;
}

/* =============================================
   LAYOUT DE DUAS COLUNAS - RESPONSIVO
   ============================================= */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* =============================================
   RESPONSIVIDADE - BREAKPOINTS
   ============================================= */

/* Tablets e telas médias */
@media (max-width: 1024px) {
    body {
        padding: 1rem;
    }
    
    .container {
        padding: 0.625rem;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    }
}

/* Tablets pequenos e celulares grandes */
@media (max-width: 768px) {
    body {
        padding: 0.625rem;
    }
    
    .container {
        padding: 0.625rem;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.625rem;
    }
    
    .header-title {
        font-size: clamp(1rem, 4vw, 1.2rem);
    }
    
    .header-user {
        text-align: left;
        width: 100%;
    }
    
    .menu {
        flex-direction: column;
        border: 2px solid #000000;
        min-height: auto;
    }
    
    .menu-item {
        border-right: none;
        border-bottom: 2px solid #000000;
        padding: 0.75rem 1.25rem;
        min-height: 44px;
        justify-content: flex-start;
        font-size: clamp(0.7rem, 2vw, 0.8rem);
    }
    
    .menu-item:last-child {
        border-bottom: none;
    }
    
    .menu-item.logout {
        margin-left: 0;
        border-left: none;
        border-top: 2px solid #000000;
    }
    
    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.625rem;
    }
    
    .card-grid .card {
        min-height: 100px;
        padding: 0.75rem;
    }
    
    .card-grid .card .value {
        font-size: clamp(1.2rem, 4vw, 1.5rem);
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        max-width: 100%;
        font-size: 1rem; /* Previne zoom automático no iOS */
        padding: 0.75rem;
    }
    
    .login-container {
        margin: clamp(1rem, 5vh, 3rem) auto;
        padding: 1.25rem;
    }
    
    .two-columns {
        grid-template-columns: 1fr;
        gap: 0.625rem;
    }
    
    table {
        min-width: 500px;
        font-size: 0.7rem;
    }
    
    th, td {
        padding: 0.5rem 0.625rem;
    }
}

/* Celulares pequenos */
@media (max-width: 480px) {
    body {
        padding: 0.3125rem;
    }
    
    .container {
        padding: 0.3125rem;
    }
    
    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .card-grid .card {
        min-height: 80px;
        padding: 0.625rem;
    }
    
    .card-grid .card .value {
        font-size: clamp(1rem, 4vw, 1.2rem);
    }
    
    .card-grid .card .label {
        font-size: 0.55rem;
    }
    
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.7rem;
        min-height: 40px;
    }
    
    table {
        min-width: 400px;
        font-size: 0.65rem;
    }
    
    th, td {
        padding: 0.375rem 0.5rem;
    }
    
    .darf-box {
        padding: 0.75rem;
        font-size: 0.65rem;
    }
    
    .login-container {
        margin: 1rem auto;
        padding: 0.875rem;
    }
    
    .login-container h1 {
        font-size: 1rem;
    }
}

/* iPhone SE / telas muito pequenas */
@media (max-width: 380px) {
    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.375rem;
    }
    
    .card-grid .card {
        min-height: 70px;
        padding: 0.5rem;
    }
    
    .card-grid .card .value {
        font-size: 0.9rem;
    }
    
    table {
        min-width: 320px;
        font-size: 0.6rem;
    }
    
    .menu-item {
        padding: 0.625rem 0.875rem;
        font-size: 0.65rem;
        min-height: 38px;
    }
}

/* =============================================
   IMPRESSÃO
   ============================================= */
@media print {
    .menu,
    .btn,
    .no-print {
        display: none !important;
    }
    
    body {
        padding: 1.25rem;
        background: white;
        font-size: 12pt;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .darf-box {
        border: 2px solid #000;
        padding: 1.25rem;
    }
    
    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* =============================================
   UTILITÁRIOS
   ============================================= */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-10 {
    margin-top: 0.625rem;
}

.mt-20 {
    margin-top: 1.25rem;
}

.mb-10 {
    margin-bottom: 0.625rem;
}

.mb-20 {
    margin-bottom: 1.25rem;
}

.hidden {
    display: none;
}

/* =============================================
   SAFARI / iOS ESPECÍFICOS
   ============================================= */
@supports (-webkit-touch-callout: none) {
    /* Correções específicas para Safari iOS */
    .menu-item,
    .btn,
    input,
    select,
    button {
        -webkit-appearance: none;
    }
    
    /* Previne zoom automático em inputs no iOS */
    select,
    textarea,
    input {
        font-size: 16px !important;
    }
    
    /* Corrige bordas arredondadas no iOS */
    input,
    select,
    textarea,
    .btn {
        border-radius: 0;
    }
    
    /* Melhora touch no iOS */
    .menu-item:active,
    .btn:active {
        opacity: 0.7;
    }
}

/* =============================================
   DARK MODE (opcional - mantém o estilo minimalista)
   ============================================= */
@media (prefers-color-scheme: dark) {
    body {
        background: #ffffff;
        color: #000000;
    }
    
    /* Mantém o fundo branco mesmo em dark mode */
    .card,
    .menu,
    .login-container,
    .darf-box,
    input,
    select,
    textarea,
    .btn {
        background: #ffffff;
        color: #000000;
    }
}