/* --- Global Resets & Variables --- */
:root {
    --color-background: #f4f4f4; /* Light Gray */
    --color-surface: #FEFDFB; /* Creamy White inspired by logo */
    --color-primary: #1a1a1a; /* Black from logo */
    --color-text-primary: #2c2c2c; /* Charcoal Text */
    --color-text-secondary: #6c757d;
    --color-accent: #495057; /* Dark grey for links/accents */
    --color-success: #198754;
    --color-error: #dc3545;
    --color-warning: #ffc107;
    --font-heading: 'Roboto Condensed', sans-serif;
    --font-body: 'Lato', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --border-color: #e9ecef;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Main Layout & Header --- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

.app-header .logo {
    width: 100px;
    height: auto;
    margin-bottom: 1rem;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--color-primary);
}

.app-header p {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

.card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-background);
    padding-bottom: 0.75rem;
    margin: 0;
}

/* --- Section Headers --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header .card-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* --- Copy Buttons --- */
.button-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button-copy:hover {
    background-color: #343a40;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(52,58,64,0.3);
}

.button-copy svg {
    width: 16px;
    height: 16px;
}

/* --- Uploader & Drop Zone --- */
.drop-zone {
    border: 3px dashed #ccc;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.drop-zone.dragover {
    border-color: var(--color-accent);
    background-color: #f0f7ff;
}

.drop-zone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-text-secondary);
}
.drop-zone-prompt svg {
    color: #aab;
}
.drop-zone-prompt .small-text {
    font-size: 0.9rem;
}

.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 100px;
    cursor: pointer;
}
.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-color: rgba(0,0,0,0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid white;
    transition: background-color 0.2s;
}
.remove-btn:hover {
    background-color: var(--color-error);
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}
.file-info {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* --- Buttons --- */
.button-primary, .button-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.button-primary {
    background-color: var(--color-primary);
    color: var(--color-surface);
}
.button-primary:hover:not(:disabled) {
    background-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.button-primary:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.button-secondary {
    background-color: #e9ecef;
    color: var(--color-text-primary);
    border: 1px solid #ccc;
}
.button-secondary:hover {
    background-color: #dee2e6;
}

/* --- Professional Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.data-table thead {
    background-color: var(--color-primary);
    color: white;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 0.875rem 1rem;
    vertical-align: top;
}

.data-table td:first-child {
    font-weight: 600;
    color: var(--color-text-primary);
    width: 30%;
}

.data-table td:last-child {
    color: var(--color-text-secondary);
}

/* --- Section-specific table styling --- */
.section-table {
    margin-bottom: 2rem;
}

.section-table .section-divider {
    background-color: var(--color-background);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-primary);
    font-size: 0.9rem;
}

/* --- Individuals Section Styling --- */
.section-table .individuals-header {
    background: linear-gradient(135deg, var(--color-primary), #343a40);
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.95rem;
    position: relative;
}

.section-table .individuals-header::before {
    content: "👥";
    margin-right: 0.5rem;
}

.section-table .section-spacer {
    background-color: transparent;
    height: 1rem;
    border: none;
}

.source-document {
    color: var(--color-text-secondary);
    font-style: italic;
    font-size: 0.85rem;
    display: block;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid var(--color-accent);
}

/* --- Individual Result Cards --- */
.result-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    background-color: white;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.result-item:hover {
    box-shadow: var(--shadow-md);
}

.result-header {
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.result-thumbnail {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.result-thumbnail:hover {
    transform: scale(1.05);
}

.result-title {
    flex: 1;
}

.result-title h3 {
    font-size: 1.1rem;
    font-family: var(--font-heading);
    margin-bottom: 0.25rem;
}

.result-status {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-status.success {
    color: var(--color-success);
}

.result-status.error,
.result-status.rejected {
    color: var(--color-error);
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* --- Collapsible Details --- */
.collapsible-details {
    border: none;
    background: none;
}

.collapsible-details summary {
    cursor: pointer;
    padding: 0;
    list-style: none;
    outline: none;
}

.collapsible-details summary::-webkit-details-marker {
    display: none;
}

.collapsible-details summary .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 2px solid var(--color-background);
    margin-bottom: 0;
}

.collapsible-details summary .card-title::after {
    content: '▼';
    font-size: 1rem;
    color: var(--color-text-secondary);
    transition: transform 0.2s ease;
}

.collapsible-details:not([open]) summary .card-title::after {
    transform: rotate(-90deg);
}

.collapsible-details[open] summary {
    margin-bottom: 1.5rem;
}

/* --- Modal for Image Viewing --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

#modal-image {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    object-fit: contain;
}

.modal-caption {
    padding: 1rem 1.5rem;
    background-color: white;
    text-align: center;
    font-weight: 600;
    color: var(--color-text-primary);
}

/* --- Error Messages --- */
.error-message {
    color: var(--color-error);
    font-weight: 600;
    padding: 1rem;
    background-color: #fff5f5;
    border-left: 4px solid var(--color-error);
    border-radius: 4px;
    margin: 1rem 0;
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Toast Notifications --- */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--color-success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.error {
    background-color: var(--color-error);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .data-table {
        font-size: 0.9rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .result-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .modal {
        padding: 1rem;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
    }
}

.app-footer {

    text-align: center;
}

.result-content {
    padding: 15px;
    background-color: #fdfdfd;
    border-top: 1px solid #e0e0e0;
}

/* Styling for the new address sub-table */
.sub-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    background-color: #f9f9f9;
}

.sub-table th, .sub-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e9e9e9;
}

.sub-table th {
    background-color: #efefef;
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
}

.sub-table td:first-child {
    font-weight: 600;
    color: #444;
    width: 150px;
}

.individual-header-row td {
    background-color: #f0f4f8;
}

.address-row > td {
    padding: 10px 15px;
    background-color: #f7f9fc;
}
.sub-table-spacer td {
    border-bottom: none;
    background-color: #f9f9f9;
    padding: 4px;
}
.nested-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}
.nested-list li {
    padding: 2px 0;
}