/* ==========================================================================
   1. Base Styles
   ========================================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem;
    background-color: #f4f7f9;
    color: #333;
}

h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   2. Layout Components
   ========================================================================== */

/* Main content box for most pages */
.content-box {
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
}

/* Wrapper for admin tables to allow horizontal scrolling */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2rem;
}

/* ==========================================================================
   3. UI Components
   ========================================================================== */

/* Forms
   -------------------------------------------------------------------------- */
.form-container {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

input[type="text"],
input[type="password"],
textarea {
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 14px;
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

textarea {
    height: 600px;
    white-space: pre;
    resize: vertical;
}

/* Buttons
   -------------------------------------------------------------------------- */
.btn {
    font-size: 16px;
    padding: 0.75rem 1.5rem;
    margin-top: 1rem;
    border: none;
    box-sizing: border-box;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s ease-out;
    text-align: center;
    display: inline-block;
}

.btn:hover {
    background-color: #0056b3;
    color: white;
    text-decoration: none;
}

.btn.btn-danger {
    background-color: #dc3545;
}

.btn.btn-danger:hover {
    background-color: #b52a37;
}

.btn.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn.btn-warning:hover {
    background-color: #e0a800;
}

.btn.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin-top: 0;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.button-group .btn {
    margin-top: 0;
}

/* Input Group (for subscription link)
   -------------------------------------------------------------------------- */
.input-group {
    display: flex;
    position: relative;
}

.input-group input[type="text"] {
    flex-grow: 1;
    margin-right: -1px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    margin-top: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-size: 14px;
    padding: 10px 1.5rem;
    border: 1px solid #007bff;
}

.copy-feedback {
    position: absolute;
    right: 120px; /* Adjust based on button width */
    top: 50%;
    transform: translateY(-50%);
    background-color: #28a745;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    pointer-events: none;
}

.copy-feedback.show {
    opacity: 1;
    transform: translateY(-50%) translateX(-10px);
}

/* Tables
   -------------------------------------------------------------------------- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    font-family: Consolas, Monaco, 'Courier New', monospace;
}

.admin-table th,
.admin-table td {
    border: 1px solid #ddd;
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background-color: #f2f2f2;
    font-weight: 600;
}

.admin-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.admin-table tr:hover {
    background-color: #f1f1f1;
}

.admin-table .action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.admin-table .action-buttons form {
    margin: 0;
}

/* Status Indicators
   -------------------------------------------------------------------------- */
.status-approved { color: #28a745; font-weight: bold; } /* Green */
.status-rejected { color: #dc3545; font-weight: bold; } /* Red */
.status-warning { color: #ffc107; font-weight: bold; } /* Orange/Yellow */


/* Banners / Alerts
   -------------------------------------------------------------------------- */
.banner {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid transparent;
}

.banner h4 {
    margin-top: 0;
    color: inherit;
}

.banner-warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
    text-align: center;
}

.banner-warning a {
    color: #856404;
    font-weight: bold;
    text-decoration: underline;
}

.banner-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.banner-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Cards (for main menu)
   -------------------------------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.card-grid a {
    text-decoration: none;
    color: inherit;
    display: flex;
}

.card {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: left;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #007bff;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-description {
    font-size: 0.9rem;
    color: #666;
    flex-grow: 1;
}

.card.card-logout {
    border-color: #dc3545;
}

.card.card-logout .card-icon {
    color: #dc3545;
}

/* ==========================================================================
   4. Page-Specific & Utility classes
   ========================================================================== */

/* Navigation Links
   -------------------------------------------------------------------------- */
.nav-link {
    text-align: center;
    display: block;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: #555;
}

/* Popups & Modals
   -------------------------------------------------------------------------- */
.success-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #28a745;
    color: white;
    padding: 1.5rem 3rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
}

/* Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    height: 100%;
    width: 250px;
    position: fixed;
    z-index: 1001;
    top: 0;
    left: -250px;
    background-color: #ffffff;
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 60px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar.active {
    left: 0;
}

.sidebar a {
    padding: 12px 15px 12px 20px;
    text-decoration: none;
    font-size: 16px;
    color: #333;
    display: flex;
    align-items: center;
    transition: 0.3s;
    gap: 15px;
}

.sidebar a:hover {
    color: #007bff;
    background-color: #f4f7f9;
    text-decoration: none;
}

.sidebar-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    color: #555;
    transition: color 0.3s;
}

.sidebar a:hover .sidebar-icon {
    color: #007bff;
}

/* Menu Toggle Button
   -------------------------------------------------------------------------- */
.menu-toggle {
    position: fixed;
    top: 15px;
    left: 15px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    z-index: 1002;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    box-sizing: border-box;
}

.menu-toggle:hover {
    background-color: #f0f0f0;
}

.menu-toggle .bar {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    border-radius: 1px;
    transition: all 0.3s ease-in-out;
}

.menu-toggle.active .bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle.active .bar:nth-child(2) { opacity: 0; }
.menu-toggle.active .bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Overlay
   -------------------------------------------------------------------------- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s, visibility 0.5s;
}

.overlay.active {
    visibility: visible;
    opacity: 1;
}

/* Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInPop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.fade-in-pop {
    animation: fadeInPop 0.5s ease-out forwards;
}

@keyframes flyOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-120%); opacity: 0; }
}

.fly-out {
  animation: flyOut 0.8s 0.2s forwards ease-in-out;
}

/* ==========================================================================
   5. Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    body {
        padding: 1rem;
        max-width: none;
    }

    .content-box {
        padding: 1.5rem;
    }

    textarea {
        height: 400px;
    }
}