/* --- Core Layout --- */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f8f9fa;
    color: #3c4043;
    padding: 1.5rem;
}

.ai-inbox-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1600px; /* Increased max-width for the entire page */
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .ai-inbox-layout {
        grid-template-columns: repeat(12, 1fr);
    }
}

.controls-column {
    grid-column: 1 / -1;
}

@media (min-width: 1024px) {
    .controls-column {
        grid-column: span 5; /* Made left column wider on larger screens */
    }
}

.results-column {
    grid-column: 1 / -1;
    min-width: 0;
}

@media (min-width: 1024px) {
    .results-column {
        grid-column: span 7; /* Adjusted right column to fit */
    }
}

/* --- Cards --- */
.controls-card, .results-wrapper-card, .auth-card {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
}

.controls-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Forms & Buttons --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #f8f9fa;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #1a73e8;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.gmail-button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background-color: #1A73E8;
    color: white;
    font-weight: 500;
    padding: 0.65rem 1.5rem;
    border-radius: 9999px; /* pill shape */
    box-shadow: 0 1px 2px 0 rgba(66,133,244,.3), 0 1px 3px 1px rgba(66,133,244,.15);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.gmail-button:hover {
    background-color: #1967D2;
    box-shadow: 0 1px 3px 0 rgba(66,133,244,.3), 0 4px 8px 3px rgba(66,133,244,.15);
}

.gmail-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.4);
}

/* --- Calendar --- */
#calendar-container .flatpickr-calendar {
    /* Style for the embedded calendar */
    box-shadow: none;
    border: none;
    width: 100%;
}
.flatpickr-calendar {
    /* Style for the pop-up (if it were ever used) */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    border: none;
}


/* --- Right Column & Results --- */
.results-wrapper-card {
    min-height: 400px;
}
.results-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #202124;
}
.instruction-text, .status-text {
    color: #5f6368;
    margin-top: 0.5rem;
}
#loadingContainer, #errorContainer, #placeholderContainer {
    display: none; /* Hide all states by default */
}
.icon-wrapper {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #bdc1c6;
    text-align: center;
}
.icon-xxl {
    font-size: 60px;
}
#loadingStatus, #errorMessage, .icon-text {
    margin-top: 1rem;
    font-size: 1.1rem;
}
#loadingMessage {
    color: #5f6368;
}
#errorContainer .icon-wrapper {
    color: #d93025;
}

/* Loader Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loader {
    border: 4px solid #e2e8f0;
    border-top: 4px solid #4285F4;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

/* Results Grid */
#resultsContainer {
    margin-top: 1.5rem;
    display: none; /* Hidden by default */
    grid-template-columns: 1fr;
    gap: 1.5rem;
}


/* Category Card Styling */
.category-card {
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.category-header {
    padding: 0.75rem 1rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}
.category-header h4 {
    font-weight: 500;
    color: #3c4043;
    text-transform: capitalize;
    margin: 0;
}
.category-header p {
    font-size: 0.75rem;
    color: #5f6368;
    font-style: italic;
    margin: 0.25rem 0 0 0;
}
.email-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

/* Email Item Styling */
.email-item {
    border-bottom: 1px solid #e0e0e0;
}
.email-item:last-child {
    border-bottom: none;
}
.email-item a {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    transition: background-color 0.15s ease-in-out;
}
.email-item a:hover {
    background-color: #e8f0fe;
}
.email-details {
    flex-grow: 1;
    min-width: 0; /* Prevents overflow issues in flexbox */
}
.email-sender {
    font-size: 0.875rem;
    font-weight: 500;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}
.email-subject {
    font-size: 0.875rem;
    color: #5f6368;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0.25rem 0 0 0;
}
.email-item .material-icons {
    color: #9e9e9e;
}

/* Auth Card and Footer */
.auth-card {
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
    padding: 2rem;
}
.auth-icon {
    font-size: 3rem;
    color: #5f6368;
}
.auth-card h2 {
    font-size: 1.5rem;
    margin: 1rem 0;
}
.auth-button {
    display: inline-block;
    margin-top: 1.5rem;
    background-color: #1a73e8;
    color: #fff;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
}
.header-bar, .footer-links {
    text-align: center;
    padding-bottom: 1rem;
}

/* AI Reasoning Card */
.ai-reasoning-card {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.reasoning-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #1967d2;
    margin-bottom: 0.75rem;
}

.reasoning-header h4 {
    margin: 0;
    font-weight: 500;
}

#reasoningText {
    margin: 0;
    color: #5f6368;
    line-height: 1.6;
}

