/* ============================================================
   FillBrim - Main Stylesheet
   Theme: White + Green (#95D040) | Header Text: #6E4E22
   ============================================================ */

/* ----- CSS Custom Properties (Theme) ----- */
:root {
    --green: #95d040;
    --green-dark: #7ab530;
    --green-darker: #649e20;
    --green-light: #eaf7d3;
    --green-lighter: #f5faeb;
    --header-text: #6e4e22;
    --black: #1a1a1a;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --red: #ef4444;
    --red-light: #fee2e2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --transition: 0.2s ease;
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    color: var(--black);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ----- Typography ----- */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--header-text);
    line-height: 1.3;
    font-weight: 700;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
}
h2 {
    font-size: clamp(1.3rem, 4vw, 1.75rem);
}
h3 {
    font-size: clamp(1.05rem, 3vw, 1.25rem);
}

p {
    color: var(--black);
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: var(--green);
    color: var(--white);
    border-color: var(--green);
}

.btn-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.btn-outline {
    background: transparent;
    border-color: var(--green);
    color: var(--green);
}

.btn-outline:hover {
    background: var(--green);
    color: var(--white);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--header-text);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--black);
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    outline: none;
    font-family: inherit;
}

.form-group input::placeholder {
    color: var(--gray-400);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(149, 208, 64, 0.2);
}

/* ----- Alerts ----- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--green-lighter);
    color: var(--green-darker);
    border: 1px solid var(--green-light);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(
        135deg,
        var(--green-lighter) 0%,
        var(--white) 50%,
        var(--green-light) 100%
    );
    padding: 1.5rem;
}

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

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand h1 {
    font-size: 3rem;
    color: var(--green);
    letter-spacing: -1px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.tagline {
    color: var(--header-text);
    font-size: 0.95rem;
    font-style: italic;
    margin-top: 0.25rem;
}

.login-form {
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-100);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 1.75rem;
    color: var(--header-text);
}

.login-logo {
    max-width: 368px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.notice-board {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: center;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: var(--white);
    border-bottom: 3px solid var(--green);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--green);
    letter-spacing: -0.5px;
}

.logo-tagline {
    font-size: 0.7rem;
    color: var(--header-text);
    font-style: italic;
}

.main-nav {
    display: flex;
    gap: 0.25rem;
}

.main-nav a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray-600);
    transition: all var(--transition);
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--green-light);
    color: var(--green-darker);
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.user-type-badge {
    background: var(--green);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.dashboard {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

.welcome {
    text-align: center;
    margin-bottom: 2.5rem;
}

.welcome h2 {
    font-size: 1.8rem;
    color: var(--header-text);
}

.welcome p {
    color: var(--gray-500);
    margin-top: 0.3rem;
    font-size: 0.95rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.tool-card:hover {
    border-color: var(--green);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.tool-icon {
    font-size: 3rem;
    line-height: 1;
}

.tool-card h3 {
    font-size: 1.1rem;
    color: var(--header-text);
}

.tool-card p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.tool-card.coming-soon {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   TOOL PAGES (Estimator, Map, Auction)
   ============================================================ */
.tool-page {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

.tool-page > h2 {
    margin-bottom: 0.5rem;
}

.tool-description {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.tool-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

/* Map & Auction placeholders */
.map-placeholder,
.auction-placeholder {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-400);
}

.map-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.map-subtitle {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: var(--gray-400);
}

/* Result panel (Estimator) */
.result-panel {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--green-lighter);
    border: 1px solid var(--green-light);
    border-radius: var(--radius);
}

.result-panel h3 {
    color: var(--green-darker);
    margin-bottom: 1rem;
}

.result-panel p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.result-panel hr {
    margin: 1rem 0;
    border: none;
    border-top: 2px solid var(--green);
    opacity: 0.3;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.footer-inner p {
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .user-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tool-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .tool-card {
        padding: 1.5rem 1rem;
    }

    .login-form {
        padding: 2rem 1.25rem;
    }

    .login-brand h1 {
        font-size: 2.2rem;
    }

    .tool-content {
        padding: 1.25rem;
    }
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 480px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }

    .main-nav a {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    .welcome h2 {
        font-size: 1.4rem;
    }

    .map-placeholder,
    .auction-placeholder {
        padding: 2.5rem 1rem;
    }

    .map-icon {
        font-size: 3.5rem;
    }
}

/* ============================================================
   USER MANAGEMENT PAGE
   ============================================================ */

/* Form layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.required {
    color: var(--red);
    font-weight: 700;
}

.user-create-form small {
    font-size: 0.8rem;
}

/* User list header */
.user-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.user-list-header h3 {
    margin: 0;
    white-space: nowrap;
}

.user-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.user-table thead {
    background: var(--gray-50);
}

.user-table th {
    text-align: left;
    padding: 0.75rem 0.75rem;
    font-weight: 700;
    color: var(--header-text);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--gray-200);
}

.user-table th a {
    color: var(--header-text);
    text-decoration: none;
    transition: color var(--transition);
}

.user-table th a:hover {
    color: var(--green-darker);
}

.user-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.user-table tbody tr:hover {
    background: var(--green-lighter);
}

.user-table tbody tr.current-user {
    background: var(--green-light);
}

/* User cell (avatar + name) */
.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.user-cell div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-cell strong {
    font-size: 0.9rem;
    color: var(--header-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-username {
    font-size: 0.78rem;
    color: var(--gray-400);
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-you {
    background: var(--green);
    color: var(--white);
}

.role-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 100px;
    white-space: nowrap;
}

.role-super_admin {
    background: #fef3c7;
    color: #92400e;
}

.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.role-seller {
    background: var(--green-light);
    color: var(--green-darker);
}

.role-buyer {
    background: #ede9fe;
    color: #5b21b6;
}

.role-miller {
    background: #fce7f3;
    color: #9d174d;
}

/* Delete button */
.btn-delete {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
    line-height: 1;
    color: var(--gray-500);
}

.btn-delete:hover {
    background: var(--red-light);
    border-color: var(--red);
    color: var(--red);
}

.btn-delete.disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

.delete-form {
    display: inline-block;
    margin: 0;
}

/* ============================================================
   ESTIMATOR PAGE — TWO-COLUMN LAYOUT
   ============================================================ */

.estimator-page {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

.estimator-page > h2 {
    margin-bottom: 0.25rem;
}

.estimator-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
}

.estimator-inputs {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.estimator-card h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-light);
    font-size: 1rem;
    color: var(--header-text);
}

/* Sticky receipt on the right */
.estimator-receipt {
    position: sticky;
    top: 90px;
}

/* Receipt card */
.receipt-card {
    background: var(--gray-800);
    color: var(--white);
    border: 1px solid var(--gray-700);
}

.receipt-card h3 {
    color: var(--white);
    border-bottom-color: var(--gray-600);
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.35rem 0;
    font-size: 0.88rem;
}

.receipt-row.receipt-deduction {
    color: #f87171;
}

.receipt-row.receipt-emphasis {
    font-weight: 600;
    color: #93c5fd;
}

.receipt-row.receipt-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--green);
    padding: 0.5rem 0;
}

.receipt-row.receipt-projection {
    font-weight: 600;
    color: #a5b4fc;
}

.receipt-divider {
    border-top: 1px solid var(--gray-600);
    margin: 0.5rem 0;
}

.receipt-price {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--gray-600);
    text-align: right;
}

.receipt-price-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 0.25rem;
}

.receipt-price-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fbbf24;
    letter-spacing: -0.5px;
}

.receipt-effective {
    margin-top: 0.5rem;
    text-align: right;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Responsive: stack on mobile */
@media (max-width: 860px) {
    .estimator-layout {
        grid-template-columns: 1fr;
    }

    .estimator-receipt {
        position: static;
    }
}

/* ============================================================
   PROFILE PAGE
   ============================================================ */

.profile-page {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

.profile-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Sidebar card */
.profile-card {
    text-align: center;
    position: sticky;
    top: 90px;
}

.profile-avatar-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.profile-avatar-large {
    width: 140px;
    height: 140px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 4px solid var(--white);
    box-shadow: var(--shadow-md);
}

.profile-avatar-edit {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--green);
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background var(--transition);
    box-shadow: var(--shadow);
}

.profile-avatar-edit:hover {
    background: var(--green-dark);
}

.profile-name {
    font-size: 1.35rem;
    margin-bottom: 0.35rem;
    color: var(--header-text);
}

.profile-username {
    color: var(--gray-400);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    margin-bottom: 1.25rem;
}

/* Meta info */
.profile-meta {
    border-top: 1px solid var(--gray-200);
    padding-top: 1rem;
    margin-top: 0.5rem;
    text-align: left;
}

.profile-meta-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0;
    font-size: 0.88rem;
    color: var(--gray-600);
}

.meta-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
}

/* Main content */
.profile-main {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.profile-section h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-light);
    font-size: 1.05rem;
}

.profile-bio {
    line-height: 1.7;
    color: var(--gray-700);
    font-size: 0.95rem;
}

/* Header link */
.user-name-link {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--header-text);
    transition: color var(--transition);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.user-name-link:hover {
    color: var(--green-darker);
    background: var(--green-light);
}

/* Textarea focus (override inline style) */
.profile-form textarea:focus {
    border-color: var(--green) !important;
    box-shadow: 0 0 0 3px rgba(149, 208, 64, 0.2);
}

@media (max-width: 768px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .profile-card {
        position: static;
    }

    .profile-avatar-large {
        width: 110px;
        height: 110px;
    }
}

/* ============================================================
   ESTIMATOR SAVE BUTTON & SAVED ESTIMATIONS
   ============================================================ */

.receipt-save {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-600);
}

.receipt-save .btn {
    font-size: 0.9rem;
}

/* Filter bar */
.filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-row .form-group {
    margin-bottom: 0;
}

.filter-row .form-group label {
    font-size: 0.78rem;
    margin-bottom: 0.2rem;
}

.filter-row .form-group select {
    padding: 0.5rem 0.7rem;
    font-size: 0.88rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.page-info {
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* Wider tool page for saved estimations */
.saved-estimations-page {
    max-width: 1100px;
}
