/* ============================================
   ENCURTADOR DE LINKS - CSS PRINCIPAL
   ============================================ */

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --dark: #1e1b4b;
    --dark-2: #312e81;
    --dark-3: #3730a3;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ---- PÁGINA DE LOGIN ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 50%, var(--primary) 100%);
    padding: 1rem;
}

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-box .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-box .logo h1 {
    font-size: 1.5rem;
    color: var(--dark);
    margin-top: 0.5rem;
}

.login-box .logo .icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

/* ---- FORMULÁRIOS ---- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--gray-50);
    color: var(--gray-800);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

/* ---- BOTÕES ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: #fff;
}

.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-outline {
    background: transparent;
    border: 2px solid var(--gray-200);
    color: var(--gray-600);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- LAYOUT PRINCIPAL ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-2) 100%);
    color: #fff;
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.5rem;
    color: rgba(255,255,255,0.7);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--primary-light);
}

.sidebar-nav li a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 1rem 1.5rem;
}

/* ---- CONTEÚDO PRINCIPAL ---- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* ---- HEADER DA PÁGINA ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* ---- CARDS ---- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 1.5rem;
}

/* ---- STATS CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

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

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

.stat-card .stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-card .stat-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-card .stat-icon.purple { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.stat-card .stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.stat-card .stat-info h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-info .stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

/* ---- SHORTENER BOX ---- */
.shortener-box {
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 50%, var(--primary) 100%);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    color: #fff;
}

.shortener-box h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.shortener-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.shortener-form .url-input {
    flex: 1;
    min-width: 300px;
    padding: 0.85rem 1.25rem;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: rgba(255,255,255,0.1);
    color: #fff;
    transition: var(--transition);
}

.shortener-form .url-input::placeholder { color: rgba(255,255,255,0.5); }
.shortener-form .url-input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
}

.shortener-extras {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.shortener-extras input {
    flex: 1;
    min-width: 200px;
    padding: 0.7rem 1rem;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: rgba(255,255,255,0.1);
    color: #fff;
    transition: var(--transition);
}

.shortener-extras input::placeholder { color: rgba(255,255,255,0.5); }
.shortener-extras input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.5);
}

/* ---- RESULTADO DO LINK ---- */
.result-box {
    display: none;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 1rem;
    backdrop-filter: blur(10px);
}

.result-box.show { display: block; }

.result-url {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.result-url input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    outline: none;
}

.result-url .btn-copy {
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.result-url .btn-copy:hover { background: rgba(255,255,255,0.3); }

/* ---- TABELA ---- */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    color: var(--gray-700);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--gray-50);
}

.data-table .url-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table .code-cell {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary);
}

.data-table .clicks-cell {
    font-weight: 700;
    color: var(--gray-900);
}

.data-table .actions-cell {
    display: flex;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-inactive { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

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

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ---- PAGINAÇÃO ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 0.85rem;
    border: 2px solid var(--gray-200);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
    font-family: inherit;
}

.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- SEARCH BAR ---- */
.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.search-bar input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ---- ALERTAS ---- */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success { background: rgba(16, 185, 129, 0.1); color: #065f46; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background: rgba(239, 68, 68, 0.1); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-info { background: rgba(59, 130, 246, 0.1); color: #1e40af; border: 1px solid rgba(59, 130, 246, 0.2); }

/* ---- TOAST NOTIFICATION ---- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

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

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}

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

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

/* ---- LOADING ---- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- PÁGINA PÚBLICA ---- */
.public-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 50%, var(--primary) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #fff;
}

.public-page .hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
}

.public-page .hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    text-align: center;
    margin-bottom: 2rem;
}

.public-box {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 650px;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ---- MOBILE TOGGLE ---- */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--dark);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.3rem;
    align-items: center;
    justify-content: center;
}

/* ---- RESPONSIVO ---- */
@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4rem;
    }
    
    .page-header { flex-direction: column; align-items: flex-start; }
    
    .stats-grid { grid-template-columns: 1fr 1fr; }
    
    .shortener-form { flex-direction: column; }
    .shortener-form .url-input { min-width: 100%; }
    
    .data-table .url-cell { max-width: 150px; }
    
    .public-page .hero-title { font-size: 1.8rem; }
}

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