/* YDulana Link Tracker – Clean modern CSS */

:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1a1d23;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem;
}

/* Top bar */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: .75rem;
    padding-bottom: .75rem;
}
.logo {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2, .card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.15rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .35rem;
    font-size: .9rem;
}
.form-group small {
    display: block;
    color: var(--muted);
    font-size: .8rem;
    margin-top: .25rem;
}
input[type="text"],
input[type="url"],
input[type="password"] {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    transition: border-color .15s;
}
input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.form-row .grow { flex: 1 1 280px; }
.form-row .form-group { flex: 0 1 220px; }

.input-prefix {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.input-prefix span {
    background: #f3f4f6;
    padding: .6rem .6rem;
    font-size: .85rem;
    color: var(--muted);
    white-space: nowrap;
    border-right: 1px solid var(--border);
}
.input-prefix input {
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.input-prefix input:focus {
    box-shadow: none;
}

.checkbox label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: .55rem 1.1rem;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    line-height: 1.3;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f9fafb; }
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm {
    padding: .3rem .65rem;
    font-size: .8rem;
}
.btn-block {
    display: block;
    width: 100%;
}

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.auth-box {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}
.auth-box h1 {
    margin: 0 0 .25rem;
    font-size: 1.4rem;
    text-align: center;
}
.subtitle {
    text-align: center;
    color: var(--muted);
    margin: 0 0 1.5rem;
}

/* Alerts */
.alert {
    padding: .85rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    font-size: .95rem;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-box {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}
.stat-label {
    font-size: .8rem;
    color: var(--muted);
    margin-top: .2rem;
}

.stats-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.stats-columns.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stats-columns.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.stat-list li {
    display: flex;
    justify-content: space-between;
    padding: .4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
.stat-list li:last-child { border-bottom: none; }

.muted { color: var(--muted); }

/* Table */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.links-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.links-table th,
.links-table td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.links-table th {
    font-weight: 600;
    background: #f8fafc;
    white-space: nowrap;
}
.links-table tr.inactive td { opacity: .6; }
.url-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}
.inline-form { display: inline; }

/* Badges */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-gray  { background: #e5e7eb; color: #374151; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
}

/* Detail page */
.detail-header p { margin: .4rem 0; }

/* Mobile tweaks */
@media (max-width: 640px) {
    .topbar-inner { flex-wrap: wrap; gap: .5rem; }
    .actions { flex-direction: column; align-items: flex-start; }
    .links-table th:nth-child(2),
    .links-table td:nth-child(2) { display: none; }
}
