:root {
    /* The Clean Divorce Palette */
    --primary: #8da36d; /* Sage Green */
    --primary-foreground: #ffffff;
    --primary-hover: #7a8f5b;
    
    --secondary: #4a5d3f; /* Darker Green */
    --secondary-foreground: #ffffff;

    --background: #fcfdfa; /* Off-white/Cream */
    --foreground: #1a1a1a; /* Dark text */

    --card: #ffffff;
    --card-foreground: #1a1a1a;

    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #8da36d;

    --muted: #f1f5f9;
    --muted-foreground: #64748b;

    --radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: #f4f6f2; /* Very light green/grey */
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease-in-out;
    z-index: 40;
    flex-shrink: 0;
}

.logo {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h2 {
    font-family: 'serif';
    font-weight: 600;
    color: var(--secondary);
    font-size: 1.25rem;
}

.sidebar nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar nav li {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted-foreground);
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar nav li:hover {
    background-color: rgba(141, 163, 109, 0.1);
    color: var(--primary);
}

.sidebar nav li.active {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

/* Main Content */
.content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    background-color: var(--background);
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.025em;
}

.primary-btn {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    padding: 0.75rem 1.5rem; /* Larger touch target */
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.2s;
    box-shadow: var(--shadow-sm);
    min-height: 44px; /* Minimum touch target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

/* Cards & Tables */
.table-container {
    background-color: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto; /* Horizontal scroll */
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 800px; /* Force scroll on small screens */
}

th {
    background-color: #f8fafc;
    color: var(--muted-foreground);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    vertical-align: middle;
}

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

tr:hover {
    background-color: #fcfdfa;
}

/* Badges & Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-green {
    background-color: #dcfce7;
    color: #166534;
}

/* Actions */
.action-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.5rem;
    color: var(--foreground);
    transition: all 0.2s;
    min-height: 36px;
}

.action-btn:hover {
    background-color: var(--muted);
}

.delete-btn:hover {
    background-color: #fef2f2;
    color: #ef4444;
    border-color: #fecaca;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 1rem;
}

.hidden {
    display: none !important;
}

.modal-content {
    background-color: var(--card);
    padding: 2rem;
    border-radius: var(--radius);
    width: 600px;
    max-width: 100%;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.5rem; /* Larger touch area */
    line-height: 1;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--foreground);
    margin-bottom: 0.4rem;
}

input, textarea, select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem; /* Prevent zoom on iOS */
    transition: border-color 0.2s;
    width: 100%;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(141, 163, 109, 0.2);
}

.submit-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    margin-top: 1rem;
    min-height: 44px;
}

/* Loading & Error */
#loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted-foreground);
}

#error-message {
    background-color: #fef2f2;
    color: #991b1b;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid #fecaca;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Submission Details */
.submission-detail {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}
.submission-detail:last-child {
    border-bottom: none;
}
.question-text {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.answer-text {
    color: var(--secondary);
}

/* Mobile Responsive */
.menu-toggle {
    display: none;
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 1024px) {
    .content {
        padding: 1.5rem;
    }
    
    .sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        background-color: white;
        box-shadow: var(--shadow);
        width: 280px; /* Wider for touch */
    }
    
    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        padding: 1rem;
        padding-top: 4rem; /* Space for hamburger */
    }

    /* Hamburger Menu */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 1rem;
        left: 1rem;
        z-index: 50;
        background: white;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        cursor: pointer;
        width: 44px;
        height: 44px;
        box-shadow: var(--shadow-sm);
    }

    h1 {
        font-size: 1.5rem;
    }

    .primary-btn {
        width: 100%; /* Full width on mobile */
        margin-top: 0.5rem;
    }

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

@media (max-width: 640px) {
    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }
    
    th, td {
        padding: 0.75rem 1rem;
    }
}
