/**
 * SIPO - CSS Dasar
 * File: assets/css/dasar.css
 * 
 * Reset, token, dan komponen dasar - RESPONSIF
 */

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #12141F;
    background: #F5F6FA;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 0.5em 0;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

a {
    color: #4F46E5;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #5C6178; }
.text-faint { color: #9498AC; }
.text-success { color: #0F7A67; }
.text-danger { color: #E0392F; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

.w-full { width: 100%; }
.hidden { display: none; }

/* ============================================================
   PRINT UTILITY
   ============================================================ */
@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
}

/* ============================================================
   TABLE DASAR
   ============================================================ */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    width: 100%;
    max-width: 100%;
}

.table-scroll .scroll-hint {
    display: none;
    font-size: 11px;
    color: #9498AC;
    margin-bottom: 6px;
    text-align: center;
}

@media (max-width: 640px) {
    .table-scroll .scroll-hint {
        display: block;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9498AC;
    text-align: left;
    padding: 0 8px 10px;
    border-bottom: 2px solid #E6E8F0;
    white-space: nowrap;
}

table td {
    padding: 6px 8px;
    border-bottom: 1px solid #EFF1F7;
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: 1px solid #E6E8F0;
}

table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table td.actions {
    text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 17px;
    border-radius: 8px;
    border: none;
    background: #0F7A67;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.12s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: #0A5D4E;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.ghost {
    background: #fff;
    color: #12141F;
    border: 1.5px solid #E6E8F0;
}

.btn.ghost:hover {
    background: #F5F6FA;
    transform: none;
}

.btn.small {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn.danger-ghost {
    background: transparent;
    border: none;
    color: #E0392F;
    padding: 4px 8px;
    min-width: auto;
    font-size: 16px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}

.btn.danger-ghost:hover {
    background: #FDECEA;
    transform: none;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field {
    margin-bottom: 4px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #5C6178;
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1.5px solid #E6E8F0;
    border-radius: 8px;
    background: #FFFFFF;
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    color: #12141F;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: #0F7A67;
    box-shadow: 0 0 0 4px rgba(15, 122, 103, 0.15);
}

.field .row-inline {
    display: flex;
    gap: 8px;
}

.field .row-inline select,
.field .row-inline input {
    flex: 1;
    min-width: 0;
}

.field textarea {
    resize: vertical;
    min-height: 60px;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    position: relative;
    overflow: hidden;
    background: #FFFFFF;
    border: 1px solid #E6E8F0;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(18, 20, 31, 0.04), 0 8px 20px -12px rgba(18, 20, 31, 0.08);
    padding: 22px;
    margin-bottom: 18px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0F7A67, #E4F5F1);
}

.card .card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
    flex-wrap: wrap;
}

.card .card-head h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
}

.card .card-head .card-sub {
    font-size: 12px;
    color: #9498AC;
}

/* ============================================================
   PAGE HEAD
   ============================================================ */
.page-head {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #F0FAF7;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    width: 100%;
    flex-wrap: wrap;
}

.page-head .icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    flex: none;
    background: #0F7A67;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.page-head h2 {
    font-size: 18px;
    margin: 0 0 2px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.page-head p {
    margin: 0;
    font-size: 13px;
    color: #5C6178;
}

/* ============================================================
   MASTER TABLE
   ============================================================ */
.master-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.master-table th {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9498AC;
    text-align: left;
    padding: 0 8px 12px;
    border-bottom: 2px solid #E6E8F0;
    white-space: nowrap;
}

.master-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #EFF1F7;
    vertical-align: middle;
    font-size: 13px;
}

.master-table tr:hover td {
    background: #F8F9FC;
}

/* ============================================================
   FORM PO - KOMPONEN KHUSUS (dipindah dari form.php agar global)
   ============================================================ */

/* COMPANY SELECTOR */
.co-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.co-card {
    border: 2px solid #E6E8F0;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #fff;
    transition: all 0.2s;
}

.co-card:hover {
    border-color: #B0B8D0;
}

.co-card.selected {
    border-color: #0F7A67;
    background: #F0FAF7;
}

.co-card .avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.co-card.kp .avatar {
    background: #0F7A67;
}

.co-card.aj .avatar {
    background: #2452E8;
}

.co-card .body .name {
    font-weight: 700;
    font-size: 13px;
}

.co-card .body .desc {
    font-size: 12px;
    color: #5C6178;
}

.co-card .body .mode {
    font-size: 11px;
    color: #9498AC;
    margin-top: 4px;
}

.co-card .check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #E6E8F0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    flex-shrink: 0;
    margin-left: auto;
}

.co-card.selected .check {
    border-color: #0F7A67;
    background: #0F7A67;
}

/* FORM GRID */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ITEM TABLE */
.item-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 660px;
    font-size: 13px;
}

.item-table th {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #9498AC;
    text-align: left;
    padding: 0 6px 8px;
    border-bottom: 2px solid #E6E8F0;
    white-space: nowrap;
}

.item-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #EFF1F7;
    vertical-align: middle;
}

.item-table input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    background: transparent;
    transition: all 0.15s;
}

.item-table input:hover {
    background: #F5F6FA;
}

.item-table input:focus {
    border-color: #0F7A67;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 122, 103, 0.12);
}

/* BTN SMALL */
.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid #E6E8F0;
    background: #fff;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #5C6178;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-sm:hover {
    background: #F5F6FA;
}

.btn-danger-sm {
    background: transparent;
    border: none;
    color: #E0392F;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 6px;
}

.btn-danger-sm:hover {
    background: #FDECEA;
    border-radius: 4px;
}

.add-row-btn {
    margin-top: 10px;
}

/* TOTALS */
.totals-box {
    display: flex;
    justify-content: flex-end;
}

.totals-inner {
    width: 280px;
    max-width: 100%;
    background: #F8FAFC;
    border-radius: 10px;
    padding: 12px 16px;
    border: 1px solid #EFF1F7;
}

.totals-inner .row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: #5C6178;
}

.totals-inner .row.grand {
    border-top: 1.5px solid #E6E8F0;
    margin-top: 4px;
    padding-top: 10px;
    font-size: 18px;
    font-weight: 700;
    color: #0A5D4E;
}

/* ACTIONS */
.actions-bar {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE FRAMEWORK
   ============================================================ */

/* MOBILE (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        padding: 8px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 16px;
    }
    .header h1 {
        font-size: 17px;
        text-align: center;
    }
    .header .nav {
        justify-content: center;
        flex-wrap: wrap;
    }
    .header .nav a {
        font-size: 12px;
        padding: 5px 10px;
    }

    main {
        padding: 16px;
    }
    main h2 {
        font-size: 18px;
    }

    /* ✅ FORM ROW → 1 KOLOM */
    .form-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    /* ✅ FORM GRID → 1 KOLOM */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* ✅ CO GRID → 1 KOLOM */
    .co-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .co-card {
        padding: 12px 14px !important;
    }
    .co-card .avatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 12px !important;
    }
    .co-card .body .name {
        font-size: 13px !important;
    }
    .co-card .body .desc {
        font-size: 11px !important;
    }
    .co-card .body .mode {
        font-size: 10px !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important;
        padding: 10px 12px;
    }
    .form-group label {
        font-size: 13px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .footer {
        font-size: 11px;
        padding: 10px 0;
    }

    .master-table {
        min-width: 500px;
        font-size: 12px;
    }
    .master-table th,
    .master-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .card {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .page-head {
        padding: 14px 16px;
        flex-direction: column;
        text-align: center;
    }
    .page-head .icon-badge {
        margin: 0 auto;
    }
    .page-head h2 {
        font-size: 17px;
    }
    .page-head p {
        font-size: 12px;
    }

    .btn {
        min-height: 44px;
        font-size: 13px;
        padding: 10px 16px;
    }
    .btn.small {
        min-height: 36px;
        font-size: 11px;
        padding: 4px 10px;
    }

    .field input,
    .field select,
    .field textarea {
        font-size: 16px !important;
        padding: 10px 12px;
    }
    
    /* ✅ ACTIONS BAR → FULL WIDTH */
    .actions-bar {
        flex-direction: column !important;
    }
    .actions-bar .btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* ✅ TOTALS BOX → FULL WIDTH */
    .totals-box {
        justify-content: stretch !important;
    }
    .totals-inner {
        width: 100% !important;
    }
    
    /* ✅ ITEM TABLE - KUNCI: max-width 100% agar tidak zoom out */
    .item-table {
        min-width: 100% !important;
        font-size: 12px;
    }
    .item-table input {
        font-size: 12px !important;
        padding: 4px 4px;
    }
}

/* TABLET (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 12px;
    }
    main {
        padding: 20px;
    }
}

/* MOBILE KECIL (max-width: 480px) */
@media (max-width: 480px) {
    body {
        padding: 0;
    }
    .container {
        padding: 4px;
    }
    .header {
        padding: 10px 12px;
    }
    .header h1 {
        font-size: 15px;
    }
    .header .nav a {
        font-size: 10px;
        padding: 4px 8px;
    }
    main {
        padding: 12px;
    }
    main h2 {
        font-size: 16px;
    }

    .card {
        padding: 10px 12px;
        border-radius: 10px;
    }

    .page-head h2 {
        font-size: 16px;
    }
    .page-head p {
        font-size: 12px;
    }

    .master-table {
        min-width: 400px;
        font-size: 11px;
    }
    .master-table th,
    .master-table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .btn {
        font-size: 12px;
        padding: 8px 14px;
        min-height: 38px;
    }
    .btn.small {
        font-size: 10px;
        min-height: 30px;
        padding: 4px 8px;
    }
    
    .item-table {
        min-width: 100% !important;
        font-size: 11px;
    }
    .item-table input {
        font-size: 11px !important;
        padding: 3px 3px;
    }
    
    .totals-inner .row.grand {
        font-size: 15px !important;
    }
    
    .co-card {
        padding: 10px 12px !important;
    }
}