@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

/* General Reset & Font Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --yellow-gradient: linear-gradient(135deg, #ffd165 0%, #ffb84d 100%);
    --bg-color: #fff9e6;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --border-color: #ffe9b3;
    --accent-color: #ffd165;
    --shadow-sm: 0 2px 8px rgba(255, 193, 7, 0.15);
    --shadow-md: 0 4px 12px rgba(255, 193, 7, 0.2);
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, #fff9e6 0%, #fff3d4 100%);
    color: var(--text-primary);
    font-size: 15px;
    padding-top: 48px;
}

/* Rate Banner */
.rate-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-start, #ffd165) 0%, var(--primary-end, #ffb84d) 100%);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
    z-index: 10000;
    transition: background 0.3s ease;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.banner-content i {
    font-size: 20px;
}

.banner-cta {
    background: white;
    color: var(--primary-end, #ffb84d);
    padding: 8px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.banner-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dashboard-container {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar-header .logo {
    width: 32px;
    height: 32px;
    margin-right: 0.75rem;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-start, #ffd165) 0%, var(--primary-end, #ffb84d) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.domain-nav {
    overflow-y: auto;
    flex: 1;
}

.domain-nav h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 0.75rem;
    margin-bottom: 0.75rem;
    margin-top: 1rem;
}

.domain-link {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.domain-link:hover {
    background-color: var(--bg-color);
}

.domain-link.active {
    background-color: var(--accent-color);
    color: var(--text-primary);
    font-weight: 500;
}

.domain-link .favicon {
    width: 16px;
    height: 16px;
    margin-right: 0.75rem;
}

.domain-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.75rem 2rem;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
}

.dashboard-title {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-start, #ffd165) 0%, var(--primary-end, #ffb84d) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    line-height: 1;
}

.theme-picker-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-start, #ffd165) 0%, var(--primary-end, #ffb84d) 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.25);
    flex-shrink: 0;
}

.theme-picker-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.35);
}

.theme-picker-btn i {
    font-size: 22px;
    color: white;
}

.theme-palette {
    position: absolute;
    top: 60px;
    left: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    padding: 16px;
    display: flex;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.theme-palette .color-swatch {
    width: 45px;
    height: 45px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-palette .color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.theme-palette .color-swatch.active {
    border-color: white;
    box-shadow: 0 0 0 3px var(--text-dark), 0 4px 16px rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container .fi-rr-search {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
    font-size: 1rem;
}

#search-input {
    width: 320px;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-start, #ffd165);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 255, 209, 101), 0.2);
}

.notes-grid {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    align-content: flex-start;
}

.note-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--border-color);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
}

.note-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-start, #ffd165);
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.note-card-title {
    font-size: 1rem;
    font-weight: 600;
    word-break: break-word;
    margin-right: 0.5rem;
}

.note-card-content-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.note-card-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    overflow: hidden;
    word-break: break-word;
    flex-grow: 1;
    max-height: 150px;
    position: relative;
    transition: max-height 0.3s ease;
}

.note-card-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.note-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    margin-left: 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.note-action-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.note-action-btn i {
    font-size: 1rem;
}

.note-action-btn.delete-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

.no-notes-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem 0;
    font-size: 1.1rem;
}

/* --- View More Styles --- */
.note-card.is-long .note-card-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--card-bg) 80%);
    pointer-events: none;
}

.note-card.is-expanded .note-card-content {
    max-height: 1000px;
}

.note-card.is-expanded .note-card-content::after {
    display: none;
}

.view-more-container {
    display: none;
    text-align: center;
    margin-top: -25px;
    margin-bottom: 10px;
    position: relative;
    z-index: 2;
}

.note-card.is-long:not(.is-expanded) .view-more-container {
    display: block;
}

.view-more-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
}

.view-more-btn:hover {
    background-color: var(--bg-color);
}

.view-more-btn i {
    font-size: 1.1rem;
    margin-right: 4px;
    line-height: 1;
}

/* --- Editing Styles --- */
.note-card.editing .note-card-content {
    padding-bottom: 40px; /* Make space for the toolbar */
    max-height: 1000px; /* Override max-height when editing */
}

.note-card.editing .note-card-title.editing {
    outline: 2px solid var(--accent-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem; /* Offset padding to maintain layout */
    background-color: #fff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.note-card.editing .note-card-content::after,
.note-card.editing .view-more-container {
    display: none; /* Hide view more elements when editing */
}

.note-card-content[contenteditable="true"] {
    outline: 2px solid var(--accent-color);
    border-radius: 4px;
    padding: 0.5rem;
    margin: -0.5rem; /* Offset padding */
    background-color: #fff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
    overflow-y: auto;
}

.note-card-toolbar {
    display: none; /* Hidden by default */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #f3f4f6; /* Light gray, fits the theme */
    border-top: 1px solid var(--border-color);
    align-items: center;
    padding: 4px 8px;
    border-radius: 0 0 6px 6px; /* Match card rounding */
}

.toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 4px;
    margin: 0 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background-color: #e5e7eb; /* Slightly darker gray on hover */
    border-color: #d1d5db;
}

.toolbar-btn img {
    width: 16px;
    height: 16px;
}

.note-action-btn.edit-btn:hover {
    background-color: #e0f2fe; /* light blue */
    color: #0284c7;
}

.note-action-btn.save-btn {
    display: none;
}
.note-action-btn.save-btn:hover {
    background-color: #dcfce7; /* light green */
    color: #16a34a;
}

.note-action-btn.cancel-btn {
    display: none;
}
.note-action-btn.cancel-btn:hover {
    background-color: #fee2e2; /* light red */
    color: #dc2626;
}

.note-card.editing .visit-btn,
.note-card.editing .copy-btn,
.note-card.editing .delete-btn,
.note-card.editing .edit-btn {
    display: none;
}

.note-card.editing .save-btn,
.note-card.editing .cancel-btn {
    display: inline-flex;
}

/* --- Custom Delete Confirmation --- */
.dashboard-delete-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(31, 41, 55, 0.75); /* text-primary with alpha */
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    padding: 1rem;
    box-sizing: border-box;
    border-radius: 8px; /* Match note-card's radius */
}

.dashboard-delete-modal p {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.dashboard-modal-buttons button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin: 0 0.25rem;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.dashboard-modal-buttons .confirm-delete {
    background-color: #ef4444; /* red-500 */
    color: white;
}

.dashboard-modal-buttons .confirm-delete:hover {
    background-color: #dc2626; /* red-600 */
}

.dashboard-modal-buttons .cancel-delete {
    background-color: #6b7280; /* gray-500 */
    color: white;
}

.dashboard-modal-buttons .cancel-delete:hover {
    background-color: #4b5563; /* gray-600 */
}

/* --- Sidebar Footer --- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.storage-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
    cursor: pointer;
    font-weight: 500;
}

.storage-link:hover {
    background-color: var(--bg-color);
}

.storage-link i {
    font-size: 1.1rem;
    margin-right: 0.75rem;
    color: #3b82f6;
}

.storage-link span {
    font-size: 0.9rem;
}
