/* ========================================
   Cyber Grow CRM - Design System
   ======================================== */

:root {
    --primary: #673de6; /* Hostinger Purple */
    --primary-light: #9d7cfb;
    --primary-dark: #4e29c2;
    --hostinger-gradient: linear-gradient(135deg, #673de6, #a855f7);
    --primary-bg: rgba(103, 61, 230, 0.06);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --orange: #f97316;
    --orange-bg: rgba(249, 115, 22, 0.1);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.1);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.1);
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e8ecf4;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --sidebar-w: 260px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    --shadow-lg: 0 4px 24px rgba(103, 61, 230, 0.12);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: linear-gradient(135deg, #f3e8ff 0%, #ede9fe 50%, #e0e7ff 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .page-header, .stat-card, .filter-bar, .table-wrap {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Delay for staggered effect */
.grid-4 > div:nth-child(1) { animation-delay: 0.1s; }
.grid-4 > div:nth-child(2) { animation-delay: 0.15s; }
.grid-4 > div:nth-child(3) { animation-delay: 0.2s; }
.grid-4 > div:nth-child(4) { animation-delay: 0.25s; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-w); height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    z-index: 100; padding: 24px 16px;
    display: flex; flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; justify-content: center;
    padding: 0 8px 24px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.sidebar-brand img {
    max-width: 200px;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    transition: var(--transition);
}
.sidebar-brand img:hover { transform: scale(1.05); }

@media (max-width: 768px) {
    .table-wrap td { 
        border: none; position: relative; padding-left: 40% !important; 
        text-align: right !important; min-height: 45px; display: flex;
        align-items: center; justify-content: flex-end; border-bottom: 1px solid #f8fafc;
        flex-wrap: wrap; gap: 4px;
    }
    .table-wrap td::before { 
        content: attr(data-label); position: absolute; left: 12px; 
        width: 35%; text-align: left; font-weight: 700; 
        font-size: 11px; text-transform: uppercase; color: var(--text-secondary);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
}

.nav-list { list-style: none; flex: 1; }
.nav-item a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--text-secondary); text-decoration: none;
    font-size: 14px; font-weight: 500; transition: var(--transition);
    margin-bottom: 4px;
}
.nav-item a:hover i { transform: scale(1.15) rotate(-5deg); transition: var(--transition); }
.nav-item.active a i { animation: pulse 2s infinite; }

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ========== MAIN CONTENT ========== */
.main { margin-left: var(--sidebar-w); padding: 28px 32px 100px; min-height: 100vh; }

/* ========== HEADER ========== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px; flex-wrap: wrap; gap: 16px;
}
.page-header h2 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    border: none; transition: var(--transition); text-decoration: none;
    font-family: inherit; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
    background: var(--hostinger-gradient);
    color: #fff; box-shadow: 0 4px 14px rgba(103, 61, 230, 0.25);
}
.btn-primary:hover { opacity: 0.95; transform: translateY(-2px); box-shadow: 0 8px 25px rgba(103, 61, 230, 0.35); }
.btn-outline {
    background: var(--card); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3); }
.btn-success { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2); }
.btn-success:hover { background: #16a34a; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; gap: 5px; border-radius: 8px; }
.btn-outline-green {
    background: transparent; color: #16a34a;
    border: 1.5px solid #16a34a; transition: var(--transition);
}
.btn-outline-green:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-2px); }
.btn-icon {
    width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; transition: var(--transition);
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--primary); border-color: var(--primary); transform: rotate(90deg) scale(1.1); }

/* ========== CARDS ========== */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); transition: var(--transition);
    overflow: hidden;
}
.card-hover:hover { transform: translateY(-6px); box-shadow: 0 12px 30px rgba(103, 61, 230, 0.08); }
.glass {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Stat Cards */
.stat-card { display: flex; align-items: flex-start; gap: 16px; position: relative; }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
    transition: var(--transition);
}
.stat-card:hover .stat-icon { transform: scale(1.1) rotate(5deg); }
.stat-info p { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-info h3 { font-size: 26px; font-weight: 700; }
.stat-trend {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600; margin-top: 8px;
}
.stat-trend.up { color: var(--green); animation: slideUp 0.5s ease-out; }
@keyframes slideUp { from { transform: translateY(5px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }


/* ========== TABLES ========== */
.table-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th {
    padding: 14px 20px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary); background: #f8fafc;
    border-bottom: 1px solid var(--border); text-align: left;
}
.table-wrap td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: #fafbff; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex; align-items: center; padding: 4px 12px;
    border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-new { background: var(--blue-bg); color: var(--blue); }
.badge-contacted { background: #f3e8ff; color: #7c3aed; }
.badge-followup { background: var(--orange-bg); color: var(--orange); }
.badge-proposal { background: var(--yellow-bg); color: #a16207; }
.badge-negotiation { background: #fef3c7; color: #92400e; }
.badge-converted { background: var(--green-bg); color: var(--green); }
.badge-rejected { background: var(--red-bg); color: var(--red); }
.badge-high { background: var(--red-bg); color: var(--red); }
.badge-medium { background: var(--orange-bg); color: var(--orange); }
.badge-low { background: var(--green-bg); color: var(--green); }
.badge-pending { background: var(--yellow-bg); color: #a16207; }
.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-partial { background: var(--orange-bg); color: var(--orange); }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--card); border-radius: var(--radius);
    width: 100%; max-width: 560px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    transform: translateY(20px) scale(0.97); transition: transform 0.25s;
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; gap: 12px; justify-content: flex-end;
    padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text); margin-bottom: 6px;
}
.form-control {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: 14px;
    font-family: inherit; background: #f8fafc;
    transition: var(--transition); outline: none; color: var(--text);
}
.form-control:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(103, 61, 230, 0.1); }
select.form-control { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ========== SEARCH & FILTER BAR ========== */
.filter-bar {
    display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
    background: var(--card); padding: 16px; border-radius: var(--radius);
    border: 1px solid var(--border);
}
.search-input {
    flex: 1; min-width: 200px; position: relative;
}
.search-input i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input input {
    width: 100%; padding: 10px 14px 10px 40px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: #f1f5f9; font-size: 14px; font-family: inherit;
    outline: none; transition: var(--transition); color: var(--text);
}
.search-input input:focus { background: #fff; border-color: var(--primary); }

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
    position: fixed; top: 24px; right: 24px; z-index: 999;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    font-size: 14px; font-weight: 500; min-width: 300px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--orange); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--green); }
.toast.error i { color: var(--red); }
.toast.warning i { color: var(--orange); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(50px); } }

/* ========== TIMELINE ========== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item::before {
    content: ''; position: absolute; left: -24px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--primary); border: 3px solid #e8e0ff;
}
.timeline-item .time { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-item .content { font-size: 14px; color: var(--text); }
.timeline-item .type-badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 6px; display: inline-block; margin-bottom: 4px;
}

/* ========== LOADING SHIMMER ========== */
.shimmer { position: relative; overflow: hidden; background: #f1f5f9; border-radius: 8px; }
.shimmer::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-secondary);
}
.empty-state i { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h4 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

/* ========== GRID HELPERS ========== */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 28px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ========== MOBILE BOTTOM NAV ========== */
.bottom-nav {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--card); border-top: 1px solid var(--border);
    padding: 8px 0; z-index: 100;
}
.bottom-nav ul { display: flex; justify-content: space-around; list-style: none; }
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--text-muted); font-size: 10px; font-weight: 600;
    padding: 6px 12px; border-radius: 8px; transition: var(--transition);
}
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); }

/* ========== MOBILE HAMBURGER ========== */
.hamburger {
    display: none; width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    align-items: center; justify-content: center; cursor: pointer;
    font-size: 20px; color: var(--text);
}
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 99;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main { margin-left: 0; padding: 20px 16px 100px; }
    .hamburger { display: flex; }
    .bottom-nav { display: block; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header h2 { font-size: 20px; }
    
    /* Responsive Table to Cards */
    .table-wrap { border: none; background: transparent; box-shadow: none; }
    .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap th, .table-wrap td, .table-wrap tr { 
        display: block; 
    }
    .table-wrap thead tr { position: absolute; top: -9999px; left: -9999px; }
    .table-wrap tr { 
        background: var(--card); border: 1px solid var(--border); 
        border-radius: var(--radius); margin-bottom: 16px; padding: 12px;
        box-shadow: var(--shadow);
    }
    .table-wrap td { 
        border: none; position: relative; padding-left: 45% !important; 
        text-align: right !important; min-height: 40px; display: flex;
        align-items: center; justify-content: flex-end; border-bottom: 1px solid #f8fafc;
    }
    .table-wrap td:last-child { border-bottom: none; }
    .table-wrap td::before { 
        content: attr(data-label); position: absolute; left: 12px; 
        width: 40%; text-align: left; font-weight: 700; 
        font-size: 11px; text-transform: uppercase; color: var(--text-secondary);
    }
    .table-wrap td div { text-align: right !important; }
    
    .modal { max-width: 100%; margin: 8px; }
    .btn { padding: 8px 16px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
    .table-wrap td { padding-left: 35% !important; }
    .table-wrap td::before { width: 30%; }
}
