/* ============================================================
   Greens Unlimited - Admin Dashboard Styles
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f8;
    color: #1a202c;
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2d5a27 0%, #4a8c3f 50%, #2d5a27 100%);
    padding: 1rem;
}

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    font-size: 1.8rem;
    color: #2d5a27;
    margin-bottom: 0.3rem;
}

.login-box .login-sub {
    text-align: center;
    color: #718096;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a8c3f;
    box-shadow: 0 0 0 3px rgba(74, 140, 63, 0.15);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: #4a8c3f;
    color: #fff;
}

.btn-primary:hover {
    background: #2d5a27;
}

.btn-secondary {
    background: #718096;
    color: #fff;
}

.btn-secondary:hover {
    background: #4a5568;
}

.btn-danger {
    background: #e53e3e;
    color: #fff;
}

.btn-danger:hover {
    background: #c53030;
}

.btn-success {
    background: #10b981;
    color: #fff;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
}

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

.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fed7d7;
    color: #9b2c2c;
    border: 1px solid #feb2b2;
}

.alert-success {
    background: #c6f6d5;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.alert-info {
    background: #bee3f8;
    color: #2a4365;
    border: 1px solid #90cdf4;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.dashboard-sidebar {
    width: 250px;
    background: linear-gradient(180deg, #2d5a27 0%, #1a3a16 100%);
    color: #fff;
    padding: 2rem 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.dashboard-sidebar .sidebar-brand {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: block;
}

.dashboard-sidebar .sidebar-brand small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

.dashboard-sidebar .nav-section {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    margin-top: 1rem;
}

.dashboard-sidebar .nav-item {
    display: block;
    padding: 0.7rem 1.5rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    opacity: 0.85;
}

.dashboard-sidebar .nav-item:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    opacity: 1;
}

.dashboard-sidebar .nav-item.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: #68d391;
}

.dashboard-sidebar .nav-item .nav-icon {
    margin-right: 0.6rem;
    width: 20px;
    display: inline-block;
    text-align: center;
}

/* Nav section toggle support - dropdown style (hidden by default) */
.dashboard-sidebar .nav-section-items {
    display: none;
}

.dashboard-sidebar .nav-section-items.open {
    display: block;
}

.dashboard-sidebar .nav-section-toggle {
    cursor: pointer;
    user-select: none;
}

.dashboard-sidebar .nav-section-toggle:hover {
    opacity: 0.8;
}

/* Arrow: ▾ points down by default, rotate 90deg to point right when collapsed */
.dashboard-sidebar .nav-section-toggle .nav-section-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
    margin-right: 4px;
    transform: rotate(90deg); /* ▾ → ▸ (right = collapsed) */
}

.dashboard-sidebar .nav-section-toggle.expanded .nav-section-arrow {
    transform: rotate(0deg); /* back to ▾ (down = expanded) */
}

.dashboard-main {
    margin-left: 250px;
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h1 {
    font-size: 1.6rem;
    color: #2d5a27;
}

.dashboard-header .user-info {
    font-size: 0.9rem;
    color: #718096;
}

.dashboard-header .user-info a {
    color: #4a8c3f;
    text-decoration: none;
    margin-left: 0.5rem;
}

.dashboard-header .user-info a:hover {
    text-decoration: underline;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fafbfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: #2d3748;
}

.card-body {
    padding: 1.5rem;
    overflow-x: auto;
}

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

.table th {
    background: #f7fafc;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

.table tr:hover {
    background: #f7fafc;
}

.table .actions {
    white-space: nowrap;
    text-align: right;
}

.table .actions a {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    margin-left: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    text-align: center;
}

.stat-card .stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    color: #2d5a27;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #718096;
    margin-top: 0.3rem;
}

/* Modal form grid - responsive 2-column layout */
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.modal-form-grid .full-width {
    grid-column: 1 / -1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #2d5a27;
    font-size: 1.4rem;
}

/* Responsive: collapse inline multi-column grids on small screens */
@media (max-width: 640px) {
    /* Collapse any inline grid element (div, form, etc.) to single column */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    /* Also collapse 3-col, 4-col inline grids */
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    [style*="repeat(5,1fr)"],
    [style*="repeat(5, 1fr)"],
    [style*="repeat(4,1fr)"],
    [style*="repeat(4, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }
    /* Reset grid-column spans to single column */
    [style*="grid-column: 1/3"],
    [style*="grid-column:1/3"],
    [style*="grid-column: 1/4"],
    [style*="grid-column:1/4"] {
        grid-column: 1 !important;
    }
    /* Modal specific overrides */
    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
        max-width: 100%;
        border-radius: 12px;
    }
    .modal-content form[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .modal-content form [style*="grid-column:1/3"],
    .modal-content form [style*="grid-column: 1/3"] {
        grid-column: 1 !important;
    }
}

.modal-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Modal form grid - 2 columns, collapses on mobile */
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-form-grid .form-group.full-width,
.modal-form-grid .full-width {
    grid-column: 1 / -1;
}

.modal-form-grid .form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    .modal-form-grid {
        grid-template-columns: 1fr !important;
    }
    .modal-form-grid .form-group.full-width,
    .modal-form-grid .full-width,
    .modal-form-grid .form-actions {
        grid-column: 1 !important;
    }
}

/* Status colors */
.status-seeded { background: #e5e7eb; color: #374151; }
.status-germinating { background: #fef3c7; color: #92400e; }
.status-growing { background: #dbeafe; color: #1e40af; }
.status-ready { background: #d1fae5; color: #065f46; }
.status-harvested { background: #fce4ec; color: #9b2c2c; }

/* Hamburger toggle for mobile */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #2d5a27;
    cursor: pointer;
    padding: 0.3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .dashboard-sidebar.open {
        transform: translateX(0);
    }

    .dashboard-main {
        margin-left: 0;
        padding: 1rem;
    }

    .sidebar-toggle {
        display: block;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.6rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 1rem;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e0;
    border-radius: 24px;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #4a8c3f;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #c6f6d5; color: #276749; }
.badge-gray { background: #edf2f7; color: #4a5568; }
.badge-warning { background: #fefcbf; color: #975a16; }
.badge-danger { background: #fed7d7; color: #9b2c2c; }

/* Form Grid Layouts */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

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