/* ========================================
   INFAQ SYSTEM - Modern CSS Design System
   ======================================== */

/* CSS Variables */
:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #22c55e;
    --secondary: #0ea5e9;
    --accent: #f59e0b;
    --dark: #1f2937;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --white: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    --transition: all 0.3s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-700);
    line-height: 1.6;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-800);
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

/* Utility Classes */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.hidden {
    display: none;
}

.block {
    display: block;
}

/* Auth Layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #1e3a5f 0%, #0d1f33 100%);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(22, 163, 74, 0.15) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.auth-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2.5rem 2rem;
    text-align: center;
    color: white;
}

.auth-header .logo {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    backdrop-filter: blur(10px);
}

.auth-header .logo svg {
    width: 36px;
    height: 36px;
}

.auth-header h1 {
    color: white;
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.auth-body {
    padding: 2rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-left: 2.75rem;
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--gray-400);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.password-toggle:hover {
    color: var(--primary);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    width: 20px;
    height: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(22, 163, 74, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(22, 163, 74, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Auth Footer */
.auth-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-200);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.auth-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Alert Messages */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* Dashboard Layout */
.dashboard-wrapper {
    min-height: 100vh;
    background: #f8fafc;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #1e3a5f 0%, #0d1f33 100%);
    color: white;
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-nav-link:hover,
.sidebar-nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav-link.active {
    background: var(--primary);
}

.sidebar-nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.main-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.topbar h1 {
    font-size: 1.75rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-800);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    border-left: 4px solid var(--primary);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-icon.blue {
    background: linear-gradient(135deg, var(--secondary) 0%, #0284c7 100%);
}

.stat-icon.amber {
    background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%);
}

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-800);
}

.stat-info p {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table td {
    font-size: 0.9375rem;
    color: var(--gray-700);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0.25rem;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--gray-300);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-400);
    margin-bottom: 1.5rem;
}

/* Form Card Grid */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.form-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.form-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.form-card-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.form-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: white;
}

.form-card-body {
    padding: 1.25rem;
}

.form-card-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--gray-200);
}

.form-card-stat:last-child {
    border-bottom: none;
}

.form-card-stat span:first-child {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.form-card-stat span:last-child {
    font-weight: 600;
    color: var(--gray-800);
}

.form-card-actions {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 0.5rem;
}

.form-card-actions .btn {
    flex: 1;
    padding: 0.625rem;
    font-size: 0.8125rem;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

/* Mobile Menu Toggle Button */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: center;
}

/* Mobile menu toggle and adjustments */
@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
    }
    

    /* Move main content to account for hidden sidebar */
    body.dashboard-page .main-content {
        margin-left: 0;
        padding-top: 0;
        margin-top: 6rem; /* Account for menu toggle button */
    }
    
    .dashboard-wrapper {
        margin-top: 0;
    }
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition);
        z-index: 999;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
    
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }
    
    .overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .user-menu {
        width: 100%;
        justify-content: space-between;
    }
    
    .auth-card {
        margin: 1rem;
    }

    .auth-header {
        padding: 2rem 1.5rem;
    }

    .auth-body {
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .forms-grid {
        grid-template-columns: 1fr;
    }
    
    .table-wrapper {
        overflow-x: auto;
    }
    
    .table {
        min-width: 600px;
    }
    
    .form-card-actions .btn {
        flex: 1;
        padding: 0.625rem;
        font-size: 0.75rem;
    }
    
    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding-bottom: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        align-self: center;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-input {
        padding: 0.75rem 0.875rem;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-info h3 {
        font-size: 1.5rem;
    }
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fade Animation */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
}

.color-option:hover,
.color-option.active {
    transform: scale(1.1);
    border-color: var(--gray-800);
}

/* Copy Link */
.copy-link {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius);
    overflow: hidden;
}

.copy-link input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.copy-link input:focus {
    outline: none;
}

.copy-link button {
    padding: 0.75rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.copy-link button:hover {
    background: var(--primary-dark);
}

/* Mobile-friendly embed code dropdown */
@media (max-width: 768px) {
    .dropdown-content {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        min-width: 90vw !important;
        max-width: 90vw !important;
        width: 90vw !important;
        max-height: 80vh;
        z-index: 1000 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    }
    
    .dropdown-content textarea {
        min-height: 120px !important;
    }
    
    .overlay-mobile-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .overlay-mobile-modal.active {
        display: block;
    }
}
