/* ===== CSS Variables ===== */
:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #17a2b8;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

.nav {
    display: flex;
    gap: 10px;
}

.nav-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-color);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--bg-color);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

/* ===== Search Box ===== */
.search-box {
    margin-bottom: 30px;
}

.search-box input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* ===== Category Section ===== */
.category-section {
    margin-bottom: 40px;
}

.category-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* ===== Bookmarks Grid ===== */
.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* ===== Bookmark Card ===== */
.bookmark-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.bookmark-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--card-color, var(--primary-color));
    background: white;
}

.bookmark-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--card-color, var(--primary-color));
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.bookmark-info {
    flex: 1;
    min-width: 0;
}

.bookmark-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookmark-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Tooltip ===== */
.bookmark-card {
    position: relative;
}

.bookmark-card[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: #1a202c;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: normal;
    max-width: 280px;
    min-width: 150px;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.bookmark-card[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    border: 8px solid transparent;
    border-top-color: #1a202c;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.bookmark-card[data-tooltip]:hover::before,
.bookmark-card[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Tooltip position adjustment for cards near edges */
@media (max-width: 768px) {
    .bookmark-card[data-tooltip]::before {
        max-width: 200px;
        font-size: 0.8rem;
    }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state.small {
    padding: 30px 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* ===== Form Styles ===== */
.form-section {
    background: var(--bg-color);
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.form-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.bookmark-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: var(--text-color);
}

.form-group input[type="text"],
.form-group input[type="url"] {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-group input[type="color"] {
    width: 60px;
    height: 45px;
    padding: 5px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.form-group small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-group small a {
    color: var(--primary-color);
    text-decoration: none;
}

.form-group small a:hover {
    text-decoration: underline;
}

.form-actions {
    display: flex;
    gap: 15px;
    padding-top: 10px;
}

/* ===== Alert Messages ===== */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== Table Styles ===== */
.list-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.table-wrapper {
    overflow-x: auto;
}

.bookmark-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.bookmark-table th,
.bookmark-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.bookmark-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

.bookmark-table tbody tr:hover {
    background: var(--bg-color);
}

.table-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.icon-cell {
    width: 60px;
}

.name-cell {
    min-width: 150px;
}

.url-cell a {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}

.url-cell a:hover {
    text-decoration: underline;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin-right: 5px;
}

.text-muted {
    color: var(--text-muted);
}

/* ===== Icon Picker ===== */
.icon-picker-container {
    position: relative;
}

.selected-icon {
    width: 60px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: white;
    transition: all 0.3s ease;
}

.selected-icon:hover {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.icon-picker {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    width: 280px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-hover);
    flex-wrap: wrap;
    gap: 5px;
}

.icon-picker.show {
    display: flex;
}

.icon-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.icon-option:hover {
    background: var(--primary-color);
    transform: scale(1.2);
}

/* ===== Form Select ===== */
.form-select {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-color);
    border-radius: 20px;
    color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    color: white;
    opacity: 0.8;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 15px 20px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main {
        padding: 20px;
    }

    .bookmarks-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .bookmark-table {
        font-size: 0.85rem;
    }

    .bookmark-table th,
    .bookmark-table td {
        padding: 10px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .nav {
        width: 100%;
    }

    .nav-link {
        flex: 1;
        text-align: center;
        padding: 10px 15px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ===== Login Page ===== */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-hover);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-muted);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.3s ease;
}

.login-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* ===== Nav Logout Button ===== */
.nav-logout {
    background: var(--danger-color) !important;
    color: white !important;
}

.nav-logout:hover {
    background: #c0392b !important;
}

/* ===== Info Section ===== */
.info-section {
    background: var(--bg-color);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    background: white;
    border-radius: var(--radius-sm);
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    font-weight: 600;
    color: var(--text-color);
}
