/* ============================================================
   KVN TAX CLOUD — Design System
   Premium dark-teal theme with glassmorphism
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    /* Brand Colors — Deep Teal/Emerald */
    --primary: #0f766e;
    --primary-hover: #0d9488;
    --primary-light: #ccfbf1;
    --primary-dark: #115e59;
    --primary-glow: rgba(15, 118, 110, 0.25);

    /* Accent */
    --accent: #f59e0b;
    --accent-hover: #d97706;

    /* Neutrals */
    --background: #f0fdfa;
    --background-alt: #f8fafc;
    --card: #ffffff;
    --card-hover: #f0fdfa;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Text */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);
    --shadow-primary: 0 4px 14px rgba(15, 118, 110, 0.2);

    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}
h1 { font-size: 1.875rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ---- Layout ---- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.page-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-content { padding: 1rem; }
}

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

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

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Stat Cards */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15, 118, 110, 0.3);
    color: #fff;
}

.btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--card);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #059669;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-warning {
    background: var(--accent);
    color: #fff;
}
.btn-warning:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--background);
    color: var(--text);
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-xl { padding: 1rem 2rem; font-size: 1.1rem; border-radius: var(--radius-lg); }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; border-radius: var(--radius-sm); }

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

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

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-input.error,
.form-select.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 0.35rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

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

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ---- Tables ---- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--card);
}

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

.data-table thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.data-table th .sort-icon {
    margin-left: 4px;
    opacity: 0.3;
    font-size: 0.7rem;
}

.data-table th.sorted .sort-icon {
    opacity: 1;
    color: var(--primary);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

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

/* ---- Badges / Status ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: var(--success-bg); color: var(--success); }
.badge-warning   { background: var(--warning-bg); color: var(--warning); }
.badge-danger    { background: var(--danger-bg); color: var(--danger); }
.badge-info      { background: var(--info-bg); color: var(--info); }
.badge-neutral   { background: #f1f5f9; color: var(--text-secondary); }

/* ---- Alerts ---- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.alert-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-item:hover {
    color: var(--primary);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ---- Multi-Step Wizard ---- */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 0 1rem;
    overflow-x: auto;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.wizard-step .step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--border);
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}

.wizard-step.active {
    color: var(--primary);
}

.wizard-step.active .step-number {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.wizard-step.completed {
    color: var(--success);
}

.wizard-step.completed .step-number {
    background: var(--success);
    color: #fff;
}

.wizard-connector {
    width: 40px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

.wizard-connector.active {
    background: var(--primary);
}

.wizard-connector.completed {
    background: var(--success);
}

.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
    animation: slideInUp 0.3s ease;
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideInUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: var(--transition);
}

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

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInRight 0.3s ease;
    font-size: 0.875rem;
    color: var(--text);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--info); }

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-close {
    margin-left: auto;
    cursor: pointer;
    color: var(--text-muted);
    background: none;
    border: none;
    font-size: 1rem;
    padding: 0 0.25rem;
}

/* ---- Search Bar ---- */
.search-bar {
    position: relative;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--card);
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-bar .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- Dropdown Menu ---- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    overflow: hidden;
}

.dropdown-menu.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.25rem 0;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

/* ---- Tax Computation ---- */
.regime-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.regime-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.regime-card.recommended::after {
    content: '✨ Recommended';
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--success);
    color: #fff;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

.tax-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.tax-row.total {
    font-weight: 700;
    font-size: 1.05rem;
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

.tax-row.refund .tax-value {
    color: var(--success);
    font-weight: 700;
}

.tax-row.payable .tax-value {
    color: var(--danger);
    font-weight: 700;
}

/* ---- Preloader ---- */
#preloader {
    display: none !important;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: inherit;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.pagination .page-btn {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.pagination .page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ---- Utility Classes ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

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

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---- Print Styles ---- */
@media print {
    .no-print, header, footer, .toast-container, .whatsapp-float { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .page-content { max-width: 100%; padding: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .wizard-steps { flex-wrap: wrap; gap: 0.5rem; }
    .wizard-connector { display: none; }
}

@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    .card { padding: 1rem; }
    .stat-card { padding: 1rem; }
    .modal { padding: 1.25rem; width: 95%; }
    .tabs { gap: 0; }
    .tab-item { padding: 0.625rem 0.875rem; font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .btn { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .form-row { grid-template-columns: 1fr; }
}
