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

:root {
    --primary: #6c5ce7;
    --primary-hover: #5a4bd1;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #adb5bd;
    --gray-700: #495057;
    --gray-900: #212529;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Auth Pages */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 0 20px;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 32px;
}

.logo {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 24px;
    letter-spacing: -1px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="datetime-local"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--gray-900);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

/* datetime-local 캘린더 아이콘 */
.form-group input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.form-group input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* 커스텀 파일 선택 */
.file-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-50);
    cursor: pointer;
    transition: all 0.2s;
}
.file-upload:hover {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.03);
}
.file-upload.has-file {
    border-color: var(--success);
    border-style: solid;
    background: #f0fdf4;
}
.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.file-upload-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.file-upload:hover .file-upload-icon { background: rgba(108, 92, 231, 0.15); }
.file-upload.has-file .file-upload-icon { background: #dcfce7; }
.file-upload-text {
    flex: 1;
    min-width: 0;
}
.file-upload-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    line-height: 1.3;
}
.file-upload-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 1px;
}
.file-upload-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 날짜/시간 그리드 */
.date-range-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.date-range-grid label {
    font-size: 13px !important;
}
@media (max-width: 480px) {
    .date-range-grid { grid-template-columns: 1fr; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    gap: 6px;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    padding: 12px;
}
.btn-primary:hover { background: var(--primary-hover); }

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
    background: #fde8e8;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

.success-msg {
    background: #d4edda;
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--gray-500);
}

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid var(--gray-200);
    padding: 24px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.admin-sidebar .logo { margin-bottom: 32px; }

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.admin-nav a:hover {
    background: var(--gray-100);
    text-decoration: none;
}

.admin-nav a.active {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.admin-main {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.admin-header h1 { font-size: 24px; font-weight: 700; }

/* Link Cards in Admin */
.link-list { display: flex; flex-direction: column; gap: 12px; }

.link-card {
    position: relative;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s;
}

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

.link-card .drag-handle {
    cursor: grab;
    color: var(--gray-500);
    font-size: 18px;
    padding: 4px;
}

.link-card .link-info { flex: 1; }
.link-card .link-title { font-weight: 600; font-size: 15px; }
.link-card .link-url { font-size: 13px; color: var(--gray-500); }
.link-card .link-clicks { font-size: 13px; color: var(--gray-500); }

.link-card .link-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* Profile Page */
.profile-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
}

.profile-avatar-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-bio {
    font-size: 14px;
    text-align: center;
    margin-bottom: 32px;
    max-width: 400px;
}

.profile-links {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-link-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    border-radius: 50px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.profile-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.profile-link-btn.style-rounded { border-radius: var(--radius); }
.profile-link-btn.style-square { border-radius: 0; }
.profile-link-btn.style-pill { border-radius: 50px; }

/* Add Link Modal/Form */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Landing Page */
.landing-hero {
    text-align: center;
    padding: 120px 20px 80px;
    max-width: 640px;
    margin: 0 auto;
}

.landing-hero h1 {
    font-size: 48px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
}

.landing-hero p {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 32px;
}

.landing-hero .btn-primary {
    width: auto;
    padding: 14px 40px;
    font-size: 17px;
    border-radius: 50px;
}

/* Mobile Top Bar */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
}

.mobile-menu-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--gray-700);
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.mobile-overlay.open { display: block; }

/* Responsive */
@media (max-width: 768px) {
    .mobile-topbar { display: flex; }

    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 100;
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-layout {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .admin-main {
        margin-left: 0;
        padding: 16px;
        padding-top: 72px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .admin-header {
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 20px;
    }

    .admin-header h1 {
        font-size: 20px;
    }

    /* Link cards 모바일 최적화 */
    .link-card {
        padding: 12px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .link-card .link-info {
        min-width: 0;
        overflow: hidden;
    }

    .link-card .link-title {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .link-card .link-url {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .link-card .link-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* 모달 모바일 최적화 */
    .modal {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* 테이블 모바일 스크롤 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .landing-hero h1 { font-size: 32px; }

    .auth-container { margin: 40px auto; }
}
