/* ==========================================================================
   Base Styles - Mobile First Approach
   Default styles for mobile, PC overrides via @media (min-width)
   Uses CSS Variables from variables.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS RESET & BOX MODEL
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base for rem calculations */
    -webkit-text-size-adjust: 100%; /* Prevent iOS font scaling */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Tahoma', 'Sarabun', sans-serif;
    font-size: var(--font-base);
    line-height: 1.5;
    color: var(--color-text-primary);
    background-color: var(--color-bg-white);
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   TYPOGRAPHY - Mobile first sizes
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-md) 0;
    font-weight: bold;
    line-height: 1.3;
}

h1 { font-size: var(--font-3xl); }
h2 { font-size: var(--font-2xl); }
h3 { font-size: var(--font-xl); }
h4 { font-size: var(--font-lg); }
h5, h6 { font-size: var(--font-base); }

p {
    margin: 0 0 var(--space-md) 0;
}

a {
    color: var(--color-text-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   LAYOUT - Mobile container
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: var(--space-sm);
}

/* PC container */
@media (min-width: 1024px) {
    .container {
        max-width: var(--container-max);
        padding: var(--space-lg);
    }
}

/* --------------------------------------------------------------------------
   FORMS & INPUTS - Touch friendly
   -------------------------------------------------------------------------- */
input,
select,
textarea,
button {
    font-family: inherit;
    font-size: var(--font-base);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: var(--touch-min); /* 44px minimum for touch */
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-white);
    font-size: var(--font-lg); /* 16px to prevent iOS zoom */
    line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* --------------------------------------------------------------------------
   BUTTONS - Touch friendly
   -------------------------------------------------------------------------- */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min); /* 44px minimum */
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-gray);
    color: var(--color-text-primary);
    font-size: var(--font-base);
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover,
.btn:hover {
    opacity: 0.9;
}

button:active,
.btn:active {
    transform: scale(0.98);
}

/* Primary button */
.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text-white);
}

/* --------------------------------------------------------------------------
   TABLES - Mobile scrollable
   -------------------------------------------------------------------------- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-base);
}

th,
td {
    padding: var(--space-sm);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

th {
    font-weight: bold;
    background-color: var(--color-bg-gray);
}

/* --------------------------------------------------------------------------
   UTILITY CLASSES
   -------------------------------------------------------------------------- */

/* Display */
.hidden { display: none !important; }
.visible { display: block !important; }

/* Flex utilities */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

/* Text utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-bold { font-weight: bold; }
.text-muted { color: var(--color-text-muted); }

/* Spacing utilities */
.m-0 { margin: 0; }
.p-0 { padding: 0; }

/* --------------------------------------------------------------------------
   PRINT UTILITIES
   -------------------------------------------------------------------------- */
@media print {
    .no-print,
    .no-print * {
        display: none !important;
    }
}
