/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
}

body.page-app {
    background: #f5f7fa;
    min-height: 100vh;
}

body.page-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ==========================================================================
   Common Components
   ========================================================================== */

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container-narrow {
    max-width: 600px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.btn-secondary:hover {
    background: #eee;
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #667eea;
    text-decoration: none;
    margin-bottom: 1rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: #333;
}

.page-header p,
.page-header .subtitle {
    color: #666;
}

.page-header .subtitle {
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c00;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #fcc;
}

/* Empty State */
.empty-state {
    background: white;
    padding: 4rem 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.empty-state h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Cards */
.card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.badge-owner {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.navbar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    padding: 8px 16px;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-link:hover {
    background: #f5f5f5;
}

.nav-link.active {
    background: #f0f0ff;
    color: #667eea;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.user-info:hover {
    background: #f5f5f5;
}

.user-info.active {
    background: #f0f0ff;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.avatar-small {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.avatar-large {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

.logout-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: #eee;
}

/* Organization Selector */
.org-selector {
    position: relative;
}

.org-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 12px;
    background: #f0f0ff;
    border: 1px solid #e0e0ff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 500;
    transition: background 0.2s;
}

.org-selector-btn:hover {
    background: #e5e5ff;
}

.org-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.org-dropdown.show {
    display: block;
}

.org-dropdown-form {
    margin: 0;
}

.org-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.org-dropdown-item:hover {
    background: #f5f5f5;
}

.org-dropdown-item.active {
    background: #f0f0ff;
    color: #667eea;
}

.org-dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

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

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ==========================================================================
   Homepage
   ========================================================================== */

.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 100px 20px;
    text-align: center;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 2rem;
    opacity: 0.9;
}

.hero .btn {
    background: white;
    color: #667eea;
}

.hero .btn:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Homepage Navbar */
.navbar-home {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: transparent;
    box-shadow: none;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-links .btn-login {
    background: white;
    color: #667eea;
}

.nav-links .btn-login:hover {
    background: #f0f0f0;
}

.user-greeting {
    color: white;
    margin-right: 0.5rem;
}

/* Features Section */
.features {
    padding: 80px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.features h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.feature-card p {
    color: #666;
}

/* Contact Section */
.contact-section {
    background: #f8f9fa;
    padding: 80px 20px;
    text-align: center;
}

.contact-section h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.contact-section p {
    color: #666;
    margin-bottom: 2rem;
}

#contact-container {
    max-width: 500px;
    margin: 0 auto;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem;
}

/* HTMX Indicators */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* ==========================================================================
   Login Page
   ========================================================================== */

.login-container {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-container .logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.login-container .subtitle {
    color: #666;
    margin-bottom: 2rem;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: #999;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.oauth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.oauth-btn svg {
    width: 24px;
    height: 24px;
}

.login-features {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
    text-align: left;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.75rem;
    color: #666;
    font-size: 0.9rem;
}

.login-feature-item::before {
    content: "\2713";
    color: #667eea;
    font-weight: bold;
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.welcome-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
}

.welcome-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.welcome-card p {
    opacity: 0.9;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-card h3 {
    color: #999;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
}

.profile-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.profile-card h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.profile-field {
    display: flex;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-field .label {
    width: 150px;
    color: #666;
    font-weight: 500;
}

.profile-field .value {
    color: #333;
}

/* ==========================================================================
   Organizations
   ========================================================================== */

.organizations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.org-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.org-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.org-card h3 {
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.org-card .meta {
    color: #666;
    font-size: 0.875rem;
}

/* Organization Detail */
.org-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
}

.org-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.org-header .meta {
    opacity: 0.9;
}

.products-link {
    display: inline-block;
    margin-top: 1rem;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.products-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Section */
.section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section h2 {
    color: #333;
}

/* Members List */
.members-list {
    list-style: none;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

.member-item:last-child {
    border-bottom: none;
}

.member-info {
    flex: 1;
    margin-left: 1rem;
}

.member-name {
    font-weight: 500;
    color: #333;
}

.member-email {
    color: #666;
    font-size: 0.875rem;
}

.member-role {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.role-owner {
    background: #f0f0ff;
    color: #667eea;
}

.role-admin {
    background: #fff3e0;
    color: #f57c00;
}

.role-member {
    background: #e8f5e9;
    color: #43a047;
}

/* ==========================================================================
   Products
   ========================================================================== */

.products-table {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.products-table table {
    width: 100%;
    border-collapse: collapse;
}

.products-table th,
.products-table td {
    padding: 1rem 1.5rem;
    text-align: left;
}

.products-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
}

.products-table tr:not(:last-child) td {
    border-bottom: 1px solid #eee;
}

.products-table tr:hover td {
    background: #fafafa;
}

.product-name {
    font-weight: 500;
    color: #333;
}

.product-serial {
    font-family: 'SF Mono', Monaco, monospace;
    color: #666;
    font-size: 0.875rem;
}

.product-date {
    color: #666;
    font-size: 0.875rem;
}

/* ==========================================================================
   Contact Form (Inline Styles Replacement)
   ========================================================================== */

.contact-form {
    text-align: left;
}

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

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

.contact-form .btn-submit {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Contact Success */
.contact-success {
    padding: 2rem;
    background: #d4edda;
    border-radius: 12px;
    text-align: center;
}

.contact-success .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.contact-success h3 {
    color: #155724;
    margin-bottom: 0.5rem;
}

.contact-success p {
    color: #155724;
}

/* ==========================================================================
   Profile Page
   ========================================================================== */

.profile-avatar-section {
    text-align: center;
    margin-bottom: 2rem;
}

.profile-avatar-section .avatar {
    margin: 0 auto 1rem;
}

.profile-avatar-section h2 {
    color: #333;
    font-size: 1.5rem;
}

.profile-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.profile-card h3 {
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.profile-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ==========================================================================
   Error Pages
   ========================================================================== */

body.page-error {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.error-container {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.error-description {
    color: #666;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   Language Selector
   ========================================================================== */

.language-form {
    display: inline-block;
    margin: 0;
}

.language-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.language-select:hover {
    border-color: #667eea;
}

.language-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
