/* CSS Variables for Premium Design System */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-color: #94a3b8;
    --sidebar-active: #38bdf8;
    --sidebar-hover: #1e293b;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-inverse: #ffffff;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eeebff;
    
    --accent: #d97706;
    --accent-light: #fef3c7;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

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

.brand-icon {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--sidebar-active);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon svg {
    width: 24px;
    height: 24px;
}

.brand h2 {
    color: var(--text-inverse);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--sidebar-color);
    transition: var(--transition);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--text-inverse);
}

.nav-item.active {
    background-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-item.active svg {
    stroke: var(--text-inverse);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
}

.sidebar-footer p {
    color: var(--text-inverse);
    font-weight: 500;
}

.sidebar-footer span {
    opacity: 0.5;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    max-height: 100vh;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-title h1 {
    font-size: 2rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

.active-profile-banner {
    display: flex;
    align-items: center;
    background-color: var(--primary-light);
    border: 1px solid rgba(79, 70, 229, 0.2);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    gap: 0.5rem;
}

.active-profile-banner .label {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}

.active-profile-banner .value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Card Styling */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: var(--transition);
}

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

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
}

.card-body {
    padding: 1.5rem;
}

.card-body.no-padding {
    padding: 0;
}

/* Tab Layouts */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

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

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .col-6 {
    flex: 1;
}

.form-row .col-8 {
    flex: 2;
}

.form-row .col-4 {
    flex: 1;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control[readonly] {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 12px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-primary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-inverse);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background-color: var(--bg-primary);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-zone:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    opacity: 0.7;
}

.upload-zone p {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.upload-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.uploaded-file-info {
    display: flex;
    align-items: center;
    background-color: var(--primary-light);
    border: 1px solid rgba(79, 70, 229, 0.15);
    padding: 1rem;
    border-radius: var(--radius-sm);
    gap: 1rem;
}

.file-icon {
    background-color: var(--primary);
    color: var(--text-inverse);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
}

.file-icon svg {
    width: 24px;
    height: 24px;
}

.file-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.file-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-clear:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--danger);
}

.btn-clear svg {
    width: 20px;
    height: 20px;
}

/* Table Styling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.table th, .table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.table-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.email-mode-toggle {
    display: flex;
    align-items: center;
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 2rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    user-select: none;
    color: var(--text-primary);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    height: 1.25rem;
    width: 1.25rem;
    background-color: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Status Indicators */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.35rem;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-pill.success {
    background-color: var(--success-light);
    color: var(--success);
}
.status-pill.success::before {
    background-color: var(--success);
}

.status-pill.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}
.status-pill.danger::before {
    background-color: var(--danger);
}

.status-pill.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}
.status-pill.warning::before {
    background-color: var(--warning);
}

/* Profile List */
.profile-list {
    list-style: none;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.profile-item:hover {
    background-color: var(--bg-primary);
}

.profile-item.active {
    background-color: var(--primary-light);
    border-left: 4px solid var(--primary);
}

.profile-item-meta {
    display: flex;
    flex-direction: column;
}

.profile-item-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0f172a;
}

.profile-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.profile-item-actions {
    display: flex;
    gap: 0.5rem;
}

.profile-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.profile-item-actions button:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--primary);
}

.profile-item-actions button.btn-delete-profile:hover {
    color: var(--danger);
}

/* File previews */
.file-preview-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: #f1f5f9;
    margin-top: 0.5rem;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: none;
}

.smtp-test-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.test-result-indicator {
    font-size: 0.85rem;
    font-weight: 600;
}

.test-result-indicator.success { color: var(--success); }
.test-result-indicator.danger { color: var(--danger); }

/* Modal Backdrops */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-box {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { width: 950px; }
.modal-md { width: 500px; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Preview Layout inside Modal */
.preview-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    height: 60vh;
}

.preview-iframe-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 100%;
}

.preview-iframe-container iframe {
    width: 100%;
    height: 100%;
    background-color: #f1f5f9;
}

.preview-worker-info {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-worker-info h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #0f172a;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.detail-row .lbl {
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-row .val {
    color: var(--text-primary);
    font-weight: 700;
    text-align: right;
}

.signature-status {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.status-indicator {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator::before {
    content: "✓";
}

.status-indicator.success {
    background-color: var(--success-light);
    color: var(--success);
}

.status-indicator.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}
.status-indicator.danger::before {
    content: "✗";
}

.w-100 { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }
.py-4 { padding-top: 2rem; padding-bottom: 2rem; }

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    background-color: var(--sidebar-bg);
    color: var(--text-inverse);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* Progress Drawer for Batch Processing */
.progress-drawer {
    position: fixed;
    bottom: -100%;
    right: 2rem;
    width: 450px;
    height: 380px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-drawer.active {
    bottom: 0;
}

.drawer-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--sidebar-bg);
    color: var(--text-inverse);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.drawer-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
}

.close-drawer {
    cursor: pointer;
    font-size: 1.5rem;
    opacity: 0.7;
    transition: var(--transition);
}

.close-drawer:hover {
    opacity: 1;
}

.drawer-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.overall-progress-bar-container {
    height: 8px;
    background-color: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.overall-progress-bar {
    height: 100%;
    background-color: var(--success);
    transition: width 0.3s ease;
}

.progress-summary {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-log-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    background-color: var(--bg-primary);
}

.progress-log-item {
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    display: flex;
    justify-content: space-between;
}

.progress-log-item.success { color: var(--success); }
.progress-log-item.danger { color: var(--danger); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
